Learn
Other mathematical assignment operators include the increment operator (++
) and decrement operator (--
).
The increment operator will increase the value of the variable by 1. The decrement operator will decrease the value of the variable by 1. For example:
let a = 10; a++; console.log(a); // Output: 11
let b = 20; b--; console.log(b); // Output: 19
Just like the previous mathematical assignment operators (+=
, -=
, *=
, /=
), the variable’s value is updated and assigned as the new value of that variable.
Instructions
1.
Using the increment operator, increase the value of gainedDollar
.
2.
Using the decrement operator, decrease the value of lostDollar
.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.