# Increment a Number with JavaScript - HELP! [Solved]

Increment a Number with JavaScript - HELP! [Solved]
0

Hi Everyone,

I’m new to Basics for Javascript and cannot for love nor money pass this. Where am I going wrong?

These are the run results.

myVar = ++myVar; //runs as myVar = 88
myVar = myVar++; //runs as myVar = 87
myVar = myVar+1; //runs as myVar = 88

Alex Liverpool UK

1 Like

It’s just `myVar++`, no equals sign needed.

3 Likes

Bingo! Thanks!! Time for Bed

Note
The entire line becomes i++;, eliminating the need for the equal sign.

Thanks for posting your question. This just helped me out also.

2 Likes

I had the same problem and now its fixed thanks @TheAlexLawless

How did you fix this problem ?
var myVar = 87;
// Only change code below this line
//myVar = myVar + 1;
myVar ++;

// running test
myVar = myVar + 1; should be changed
// tests completed
where i should change?

Delete all your commented sections, because the testing program is not too smart and thinks you are trying to solve the problem with myVar = myVar + 1 still (even though it is commented out). It is a bug in the tests.

1 Like

Thanks Now its Working fine

the sulution is myVar++

like the example
i = 1;
i = i + 1;
or myVar = myVar + 1 ;

I am having an issue too.

This is my code:

var myVar = 87;

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

I am getting this message:

// running tests
myVar = myVar + 1; should be changed
// tests completed

basically i am getting all checkmarks aside from that one.

You need to close out the line with a semi-colon. That will complete it for you.

I guess im having the same issue as most here. Here’s what I did and what im getting.

var myVar = 87;

// Only change code below this line

myVar = myVar ++;

// running tests

myVar should equal 88

myVar = myVar + 1; should be changed

// tests completed

Is there a bug in this question or am I missing something?

I guess all I had to do was get rid of the “myVar =” and just have it look like this,
// Only change code below this line
myVar++;

I was going nuts over this, lol
Happy Coding Everyone!

finally I got it! )

Basically, don’t add the myVar = myVar++;

So:
//Only change code below this line
myVar++;

It should let you complete the test after that