(Increment) a Number with JavaScript

(Increment) a Number with JavaScript
0

#1

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

#2

No increment here I think.


#3

You only need to modify the original line of:

myVar = myVar + 1;

Do not add any additional lines of code.

If you look at the example in the challenge instructions, you will see how i++; replaced i = i + 1;

You need to apply the same principle to your code. myVar is a variable just like i is in the example.


#4

I don’t understand can you explain me more σιμπλε


#5

What do you not understand?


#6

can you tell me more simple that all


#7

You still have to tell me exactly what you do not understand? I do not know if you do not understand what the instructions are asking you to do or if you do not understand what the ++ operator does. We can not help you unless you explain what you want help with.


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

both lines will add 1 to the number.


#9

I don’t understand where to put the myVar=myVar


#10

Delete it. It is useless.


#11

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.


#12

thank for your help but i did it


#13

[quote=“Logiar, post:11, topic:180754”]
Thank you for 1. Being NICE 2. Being Specific and helpful