Increment a Number with JavaScript?

Increment a Number with JavaScript?
0.0 0

#1

Tell us what’s happening:
Hi, I’m trying to increment this variable and am kind of confused as to why its not working.

Your code so far


var myVar = 87;

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1 Safari/605.1.15.

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


#2

the = operator is an assignment. So what you’re telling the computer to do is

  • assign the variable myVar to the value of myVar++.

when what you want to do is

  • increase the value of myVar

#3

I just got that, I thought I was supposed to reassign the value. Thanks!