Storing Values with the Assignment Operator Help! A should be assigned to B

Storing Values with the Assignment Operator Help! A should be assigned to B
0

#1

Tell us what’s happening:
Help! A should be assigned to B

Your code so far


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

// Only change code below this line

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:61.0) Gecko/20100101 Firefox/61.0.

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


Storing Values with the Assignment Operator assigning a to be
#2

so the first thing you had to do was assign 7 to a, which you did perfectly by writing:

a = 7;

Now, they want you to assign a to b. So, just do the exact same thing you did but with a and b.
(that is, if I said, assign 20 to b, then you would write b = 20 right? So a to b is no different than 20 to b. Exactly the same but instead of 20 , use a).


#3

Like: var b = a;
Thanks brain raked a bit an i’m just starting.


#4

In the example it was written

myNum = myVar;

So I thought it is enough if I write a=b; since they are both variables. But nope, it does not work. var a=var b; also does not work. Example was wrong! :slight_smile:


#5

What’s your current code? If you use the Ask for help button you can create a post with your code and we will be able to see it and help you (or copy your post here formatting it with the backticks! In the post editor you can use the </> button)

Anyway, it is correct that you can assign the value of b to a using a = b
var a = var b is a syntax error. var is the keyword to declare a variable, it can’t be used in the part that is going to be assigned


#6

Also they want you to assign a to b, not b to a


#7

I misunderstood the task but now I understand. Thanks, I really tried to assign a to be when a is 7. My bad.