Tell us what’s happening:
I put myvar = myvar++;
and it wasnt correct what am I doing wrong?
Your code so far
myVar = myVar++;
var myVar = 87;
// Only change code below this line
myVar = myVar++;
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/increment-a-number-with-javascript
ilenia
July 8, 2019, 9:30am
#2
Astralwolf:
myVar = myVar++;
the following three are equivalents, note that there is not a a = a++;
, as that is not correct
a = a + 1;
a += 1;
a++;
myVar++ returns the value that was before the increment, you don’t need to re-set the value, just do:
myVar++;
If you want to re-set the value you could do a “increment first” operation by adding the “++” as a prefix as such:
myVar = ++myVar;
I only put myVar++; and it worked so whats the whole a++ thing about
he was giving you an example with a
instead of myVar
ilenia
July 9, 2019, 6:36am
#6
If I did the thing with myVar
it wouòd have the answer directly, instead I was showing you the correct syntax with a different variable so that you can learn to apply it!