Could someone please explain to me why the answer is not myVar++; ...?

Tell us what’s happening:
Describe your issue in detail here.

Your code so far


let myVar = 87;

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36

Challenge: Increment a Number with JavaScript

Link to the challenge:

I don’t understand your question.

Your code doesn’t work. The failing test says:

myVar should equal 88.

If I add this to the bottom of your code, I can see it is indeed failing that test:

console.log(myVar);
// 89

I don’t understand what you are asking with:

Could someone please explain to me why the answer is not myVar++; …?

I don’t understand the question because it can be. Can you show us the complete code that you think should pass but doesn’t?

1 Like

let myVar = 87;

// Only change code below this line

myVar = myVar + 1;

myVar++;

myVar should equal 88

Thanks for your response. My answer to the challenge was “myVar++;” Does this help?

Hi,
i think, the test does not work because you have to delete “myVar = myVar + 1”, which you replace with “myVar++”.

3 Likes

That worked. Thank you :slight_smile:

1 Like