Wednesday, May 5, 2021

Javascript Practice 28: JS Hero - Increment

 
Question: 

Which value does x have after execution of the following code?

let x = 3;
x++;
x = x * 2;
x--;




Answer: 

x has a value of 7 

> x = 3
> x++:  3+1 = 4
> x = x*2; i.e. 4*2 = 8
> x--: 8-1 = 7

No comments:

Post a Comment