Increment a Number with JavaScript - HELP! [Solved]

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

#1

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


#2

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


#3

Bingo! Thanks!! Time for Bed :relieved:


#4

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

:slight_smile:


#5

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


#6

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


#7

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?


#8

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.


#9

Thanks Now its Working fine :slight_smile:


#10

the sulution is myVar++

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


#11

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.


#12

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


#13

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?


#14

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!