Assign the contents of a to variable b

Tell us what’s happening:

Can’t figure out what it means by “Assign the contents of a to variable b.”. I’ve tried using combinations of with var and without var and nothing will work.

Your code so far


// Setup
var a;
var b = 2;

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

Your browser information:

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

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

You don’t need to declare the same variable in the same scope two times

I’ve tried both var a = b and var b = a and it tells me “a should be assigned to b with =”

a should be assigned to b, not var a, if var a was already declared before

Here is a example of declare and assign a value into a variable. Read carefully the challenge. Good Luck :+1:

// declare var
var a;
// assign value
a = "somecontent"

this one is a bit strange but:

// Setup
var a;
var b = 2;

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

1 Like

you use var only when you declare the variable the first time, so in the code you need to add there’s should be no var as the two variables a and b already exist

other thing, you assign 7 to a, then a to b
it is never mentioned to assign 7 to b, but you did that