Increment a Number with JavaScript - What's wrong

Tell us what’s happening:

This challenge doesn’t seem to be difficult but I’m confused,
could smbd tell me what’s wrong with my code?

it writes bellow:

// running tests
myVar = myVar + 1; should be changed
// tests completed

but, as you can see it’s been changed

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 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.142 Safari/537.36.

Link to the challenge:

The challenge explain the shortcut ++ which increments the value to which is applied
For example a = a + 1 is equivalent to a++

1 Like

The thing is that your syntax is wrong. This line myVar = ++myVar is incorrect.
It should be like this myVar += 1 or myVar++ or ++myVar.
My guess is that you need to use the first solution I proposed. :vulcan_salute:

1 Like