myVar = myVar + 5;
to add 5 to myVar. Since this is such a common pattern, there are operators which do both a mathematical operation and assignment in one step.
One such operator is the += operator.
var myVar = 1;
myVar += 5;
console.log(myVar); // Returns 6
a, b, and c to use the += operator.
a should equal 15
testString: assert(a === 15, 'a should equal 15');
- text: b should equal 26
testString: assert(b === 26, 'b should equal 26');
- text: c should equal 19
testString: assert(c === 19, 'c should equal 19');
- text: You should use the += operator for each variable
testString: assert(code.match(/\+=/g).length === 3, 'You should use the += operator for each variable');
- text: Do not modify the code above the line
testString: assert(/var a = 3;/.test(code) && /var b = 17;/.test(code) && /var c = 12;/.test(code), 'Do not modify the code above the line');
```