Increment a Number with JavaScript: How to Change "myVar = myVar + 1"? [To be CLOSED]

Tell us what’s happening:

Hi everyone,

So far I have done everything right on the exercise, except for the part where it asks me to change “myVar = myVar + 1”.

I even tried reversing the original equation, as in “myVar + 1 = myVar”, but with no success as it turned out to be syntax error.

With that said, how could I successfully change it as the exercise is asking me to? Also, what would “change” mean in this case? How would any of the characters in the equation need to be modified?

Many thanks in advance.


Your code so far

var myVar = 87;

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

Your browser information:

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

Link to the challenge:

It works the same way with - as it does with +.

The question states that i = i + 1 equals i++. So your myVar = myVar++ has an unnecessary variable declaration. So just get rid of the original myVar = myVar + 1 and the variable declaration and it should pass.

You are trying to re-declare the variable in your code. It is already declared as 87, you just want to increment it, thus passing it ++. the line would just look like —> myVar++

1 Like

It did pass. I appreciate your help!