I'm having trouble trying to get a to equal to b

Tell us what’s happening:

Your code so far


// Setup
var a;
var b = 2;

// Only change code below this line
myVar = myNum;
var a = 7;
var b = 7;

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36.

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

They don’t want you to assign 7 to b, they want you to assign the value of a to b. There’s a difference.

Reference the example.

i must be stupid, i still don’t know what to do

Don’t worry about it.

The example shows:

myVar = 5;
myNum = myVar;

So rather than doing what you did, what this exercise is trying to show you is that when you give a value to a variable, in this case myVar = 5, myVar now has 5 stored in it. Now whenever myVar is used ( meaning that it will be on the right side of the ‘=’ ) it will have the value of 5.

So myNum = myVar can now be thought to read “shove whatever is stored in myVar in to myNum”.

1 Like

so i typed in this:

myVar = 7;
myNum = myVar;

and it’s still not correct

Right. Because they are asking to use the variables a and b. I just copied and pasted the example, because it’s bad mojo to just give you the answer hahaha.

well im stuck, i’ve tried so many variations and i’m still not getting it

What do you have now?

be sure to use ‘a’ and ‘b’ for your variable names. Do not use the ones in the example shown in the challenge ‘myNum…’