๐ฉPlus (+) operator
In JavaScript, the +
operator is used for addition and string concatenation.
For example:
let x = 1 + 2; // x is 3
let y = 'Hello' + ' World'; // y is "Hello World"
The +=
operator is a compound assignment operator that is used to add a value to a variable and assign the result to that variable. It is a shorthand version of writing variable = variable + value
.
For example
let x = 1;
x += 2; // x is now 3
let y = 'Hello';
y += ' World'; // y is now "Hello World"
Let's see another example in the context of a "Strategy Game"
Last updated