Increment a Number with JavaScript HELP!

Tell us what’s happening:

What am I doing wrong?

Your code so far


var myVar = 87;

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

Your browser information:

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

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

Hi you happen to resetting the value of myVar, with the statement myVar = 88; Also I forgot to mention it doesn’t need to be myVar = myVar++. “myVar++” will increment the value of the variable automatically.

Hi Raregamer, apologies I am still not quite understanding

So would it be like

myVar++ = 88

no, that’s a syntax error
also, the tests ask for the variable to be a specific number, but you don’t write that number in that code, you use the incrementing operator to raise the existing variable

this challenge is teaching about ++ operator

the three following lines do the same exact thing:

i++;
i += 1;
i = i + 1;

Hi so var myVar = 87. myVar is the variable and currently holds the number 87. Now we have to increment that value. We can do that with a syntax shortcut which would just be myVar++. Now myVar = 88. This can also work with subtraction myVar–; that would subtract one, from the current value.

As a reminder myVar = myVar + 1; is the same as myVar++;