The Increment and Decrement Operator

 VARIABLES

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 a10;
a++;
console.log(a); // Output: 11
let b20;
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.


Solutions:

let gainedDollar = 3;
let lostDollar = 50;
gainedDollar++;
lostDollar--;


Comments