Increment a Number with JavaScript - HELP! [Solved]

Hi Everyone,

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

These are the run results. :tired_face:

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.

4 Likes

Bingo! Thanks!! Time for Bed :relieved:

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

:slight_smile:

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?

Thanks Now its Working fine :slight_smile:

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! :smile: )

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

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

It should let you complete the test after that

var myVar = 87;

// Only change code below this line

++ myVar;