Basic JavaScript: Storing Values with the Assignment Operator

what the hell is wrong with this thing here it won’t f***king work
I need f***king help here is the problem In JavaScript
a = 7;

b = 7;

a = b;
the last one doesn’t work so help me please!!!

So you have three lines, and you really only need two. You are told to do this:

Assign the value 7 to variable a .

Assign the contents of a to variable b .

So, your first line is exactly right. a = 7; does, indeed, assign the value 7 to the variable a.

Your second line, however, is not so right. You aren’t being told to assign the value 7 to b, but the value in a to the value in b.

Personally, I’d get rid of the SECOND line, and flip the THIRD – you want to set b equal to a, and not the other way around.

1 Like
myVariable = 5;
This assigns the  `Number` value  `5` to  `myVariable` .
Since we learned that a variable is like an a our b in math it means we need to assign something to it. 
a+1=?
a is in this case a variable
So we go and assign a 7 to it as it tells us there what to do
Assign the value  `7` to variable  `a` .
a = 7;
Then we are told the next 
Assignment always goes from right to left.
now we know this we can Assign the contents of  `a` to variable  `b` .
from right b = a; left
1 Like