Increment a Numbers with JavaScript

Tell us what’s happening:

Your code so far


var myVar = 87;

// Only change code below this line
myVar = 87 + 1;
++87;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/increment-a-number-with-javascript/

I can’t seem to be getting how to use ++ to make number to be 88

Try this and see if you can understand what is happening. Then change the myVar accordingly.

var i = 0;
console.log("this is the iniliasation of the value i: " + i);
i++;
console.log("this is the endvalue of i : "+ i);

An extra tip. You need to change the exact line of myVar = 87 + 1;

1 Like

If you’re trying to get a counter to increment myVar at every run:

var myVar = 87;
function updatevar(){
return console.log( myVar++);
}
updatevar(); // 87
updatevar(); // 88
updatevar(); // 89

1 Like

Just replace myVar = myVar + 1; with myVar++;
Because myVar = myVar + 1; is same as myVar++;

1 Like