(Increment) a Number with JavaScript

This is my code so far.What i could wrong??

Your code so far

var myVar = 87;

// Only change code below this line
myVar = myVar; //runs as myVar = 88
myVar = myVar++; //runs as myVar = 87
myVar = myVar+1; //runs as myVar = 88```
**Your browser information:**

Your Browser User Agent is: ```Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.162 Safari/537.36```.

**Link to the challenge:**
https://www.freecodecamp.org/challenges/increment-a-number-with-javascript

No increment here I think.

I donā€™t understand can you explain me more ĻƒĪ¹Ī¼Ļ€Ī»Īµ

can you tell me more simple that all

myVar++; // this is the same as...
myVar = myVar+1; //this

both lines will add 1 to the number.

1 Like

I donā€™t understand where to put the myVar=myVar

Delete it. It is useless.

Looking at the problem youā€™re just supposed to change the code to use ++, this is a little tricky if you donā€™t know how the return works. myVar++; will increment myVar, but return the old value of myVar.
So myVar = myVar++; does not actually change the value. ++myVar will increment and return the new value so myVar = ++myVar; would work, but itā€™s unnecessary. the whole myVar = myVar + 1; can be replaced with simply myVar++; by itself.

2 Likes

thank for your help but i did it

1 Like

[quote=ā€œLogiar, post:11, topic:180754ā€]
Thank you for 1. Being NICE 2. Being Specific and helpful