How to assign one variable to another

Tell us what’s happening:
For whatever reason, I can’t pass this challenge, even though it is very simple. It requires assigning variable a to variable b.

Your code so far


// Setup
var a;
var b = 2;

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15.

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

Re-read the challenge description carefully.

Assignment always goes from right to left. Everything to the right of the = operator is resolved before the value is assigned to the variable to the left of the operator.

The challenge description also includes an example of assigning the value of one variable to another.

I have done this already. I keep putting a on the right side of the equation and b on the left. This resolves nothing.

Add semicolons at the end of each statement

Still not working. This is what I currently have:

a = 7;
b = 7;
a = b;

1.) They want you to change the code so you shouldn’t have the first 2 lines there.

a = 7;
b = 7;

2.) It is wanting you to assign a to b, correct?
So think hard about what you are actually doing in this line of code:
a = b;

The challenge states the following conditions:
a should have a value of 7
b should have a value of 7
a should be assigned to b with =

Why is everyone being so bloody cryptic around here?

Hello? Is anyone there?

Nobody is being cryptic. Everyone is trying to help you.
You need to assign 7 to the variable a.
You need to assign the value of a to the variable b.
You do not need to do anything else.

I am doing exactly that, and nothing is happening.


This is what I currently have.

This is what you are doing:
Assigning 7 to variable a
Assigning 7 to variable b
Assigning content of variable b to variable a

So it is not exactly what you are being asked to do

I managed to solve it. God damn it.

How did you manage to work it out?

If you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

This topic has been inactive for two years and the challenge is pretty different now.

Thank you.