Tell us what’s happening:
a should be assigned to b with =.
Your code so far
a = 7;
// Only change code below this line
b = 7;
a = b;
Your browser information:
User Agent is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.124 Safari/537.36 Edg/102.0.1245.44
Challenge: Assigning the Value of One Variable to Another
Link to the challenge:
I’ll give you a hint. You should only add one line of code. You already have the variables
b declared and
a has the value of
7. You just want to put the value in
b. But don’t use the number
7 in your answer. You can only use the variables.
it should be
b = a ;
as value is assigned to b .
Please don’t give answers here. We try to help people find the answers for themselves.
Just curious as to why a = b; doesn’t work. Seems the same to me.
The variable on the left hand side of the equals sign gets the value on the right hand side of equals sign. So
a = b says “put the value of
b doesn’t have a value (it’s technically
undefined). What you want is “put the value of
b needs to be on the left hand side of the equals sign.
here ‘b’ is the container and it will get the value of ‘a’ as its content .
eg :- if a has some value b will get that value ;
it is kinda same when we use ‘==’(equal to operator)
This isn’t really true. The single equals sign is for assignment. The double equals sign is checking equality. Two different things.
will keep that in my mind for next time .(BTW it is my 1st reply so. I was waiting for a solution to my problem.)
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.