Storing Values with the Assignment Operator- help

Tell us what’s happening:

Your code so far


// Setup
var a;
var b = 2;

// Only change code below this line
var a = 7;
var b = 7;
a = b;

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Firefox/60.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator/

You have your var a assigned to 7 so this is correct. However, you do not need to assigned var b to 7 as the exercise is not asking you to do this. For assigning the contents of a to variable b, remember that everything to the right of the assignment operator (=) is resolved first. Therefore, you’ll want to assign b = a.

A simplified explanation:

var a; means Please give me some space to store some data in it and let me refer with "a" to it

a = 5; means Please put the value 5 into the space, the "a" refers to

var a = 5; means Please give me some space to store some data in it and let me refer with "a" to it. Then put the value 5 into this space..

1 Like