Tell us what’s happening:
Describe your issue in detail here.
I’m failing on this task : You should not use the assignment operator.
Your code so far
let myVar = 87;
// Only change code below this line
myVar = myVar + 1;
myVar = 87;
myVar++;
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36
Challenge: Increment a Number with JavaScript
Link to the challenge:
These two lines are using the assignment operator (=
):
myVar = myVar + 1;
myVar = 87;
The instructions were:
Change the code to use the ++
operator on myVar
.
You we supposed to change the bottom line, which was:
myVar = myVar + 1;
Don’t add lines after this, change this line.
Hint: try the code below
redacted
And then tell if it worked .
It’s great that you want to help out, but please don’t give the answers, especially on challenges. We try to guide people to finding the answer.
1 Like
@kevinSmith sorry my friend, I promise this won’t happen anymore.
1 Like
Cool, it happens. No biggie.
Do not reassign value to myVar .
Code line below comment is already doing the increment by one in myVar . You need to modify it by using the “++” operator. Simply use increment operator instead of assignment (=) operator.
e.g.
let a = 5;
// inreament
a++;
1 Like
Super helpful, thanks for this break down.
system
Closed
October 6, 2022, 1:39pm
9
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.