Tell us what’s happening:
Your code so far
// Setup
var a;
var b = 2;
// Only change code below this line
Assign the value 7 to variable a.
Assign the contents of a to variable b.
**Your browser information:**
User Agent is: <code>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36</code>.
**Challenge:** Storing Values with the Assignment Operator
**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator
What have you tried? What do you have questions about?
Everything, What does Assign contents of a to b mean?
After you assign a value to a
, that value can be referred to as "the contents of a
".
var a = 87; // the variable a now contains 87
so in this case I should type b = 7; but when I do it gives error and the correct answer is b = a, but it should say b = 7 because it assign the contents of a?
That would just be assigning 7
to b
. You need to use the variable a
to assign it’s value to b
. If you look at the example code in the lesson, it explains how to assign one variable to the value of another.
Okay thank you very much, I really appreciate your help, I got it now.
Congratulations. Happy coding!