Jav help with easy things

Tell us what’s happening:
What do I need to do?:frowning:

Your code so far

// Setup
var a;
var b = 2;

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

Your browser information:

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

Link to the challenge:

1 Like

The last requirement is: a should be assigned to b with =.
What you did was “var b = 7” which means that you assigned b to 7.
Also, there is no need to use var since a and b were declared under the “Setup” comment.

Let’s look at your code and make sure you followed the instructions.

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

First, they ask you to assign the value 7 to variable a.
Your first line (see below) meets that instruction. OK, so far so good.

var a = 7;

Next, they ask you to assign the contents of a to variable b. When we look at your next line of code (see below)

var b = 7;

you assigned the value 7 to the variable b. This is not what the instructions asked you to do, so you you are not passing the test.

Finally, in the last line (see below)

a = b;

you do assign the contents of b to variable a. This again, does not meet the requirements of the instructions.

Remember, when we write:

var myVariable = 100;

the = (equals sign) assigns the value on the right side of it to whatever is on the left side of it. So the above is assigning the value 100 to the variable myVariable.

Now, see if you can finish the challenge correctly this time. You already have the first line correct and now you only need a second line of code to pass the challenge. You do not need 3 lines to solve it.