- Increment a Number with JavaScript -

Tell us what’s happening:
When I run the test it says myVar should equal 88. So why doesn’t it equal 88 when I add the ++ to myVar?

Your code so far


var myVar = 87;

// Only change code below this line
myVar = myVar++;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/increment-a-number-with-javascript

You don’t need the assignment.

myVar++;

is the same as

myVar = myVar + 1;
3 Likes

Thank you. It works now.