Basic JavaScript - Assigning the Value of One Variable to Another

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

// Setup
var a;
a = 7;
var b;

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

Your browser information:

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

Challenge: Basic JavaScript - Assigning the Value of One Variable to Another

Link to the challenge:

Hi my name is mush for brains. Appreciate someone being able to point out the obvious to me here.

I cannot think why, if making sure a and b are the assigned the same value. Why would the below not be true

a = b

So basic, but also tricky!

You should not do this.

This puts the contents of b into a. The challenge wants you to put the contents of a into b.

Hi Jeremy - thank you very much.

If I could pick your brains a little bit so I won’t go wrong again. Why would the order make a difference if the values are the same?

That’s how the syntax works. It assigns a value into a variable. The variable goes on the left. The value goes on the right.

Got it - thanks a lot!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.