Increment a Number with JavaScript incorrect

Increment a Number with JavaScript lesson is incorrect.

The lesson suggests that i++ is the equivalent of i + 1; however the lesson will only work if you replace myVar = myVar + 1, with myVar = ++myVar.

myVar = myVar++

Your code so far


let 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/100.0.4896.127 Safari/537.36

Challenge: Increment a Number with JavaScript

Link to the challenge:

It is mentioned that "Change the code to use the ++ operator on myVar " which means you can only add the ++ operator either in the form of postfix or prefix. You are not allowed to use

myVar = myVar +1;

You can only use one notations from below

[redacted]

That would be incorrect. But the lesson doesn’t say that. Here’s what it says:

i++;

is the equivalent of

i = i + 1;

That is different than what you have written. What is written in the lesson is correct.

2 Likes

Please don’t give the answers to challenges. Try to guide them. We’re a learning platform.

Hi there,

nice to meet you!

If you re-read the instructions, it says:

i++;

is the equivalent of

i = i + 1;

Can you spot the difference between your sentence and the instruction’s sentence?

1 Like

I’m sorry, will be careful next time.

1 Like

Thanks for your help

Thanks for your help.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.