xxxxxxxxxx
// THE DIFFERENCE BETWEEN "+" AND "+=" IN JAVASCRIPT:
let a = 2;
console.log(a + 3); //expected output: 5
console.log(a); //expected output: 2
let a = 2;
console.log(a += 3); //expected output: 5
console.log(a); //expected output: 5
xxxxxxxxxx
let a = 2;
let b = 'hello';
console.log(a += 3); // addition
// expected output: 5
console.log(b += ' world'); // concatenation
// expected output: "hello world"
xxxxxxxxxx
Addition assignment (+=) The operator ( += )
adds the value of the right operand to a variable