Basic JavaScript - Assigning the Value of One Variable to Another

Hello,

Would someone know what the error is here please?

Your code so far

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

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

Your browser information:

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

Challenge Information:

Basic JavaScript - Assigning the Value of One Variable to Another

Hi,

var is a javascript keyword that you are using to declare a variable.
Here with the help of var you have declare two variable a and b.
And you have successfully assign a value of 7 to variable a. Now you have to assign the variable a to the b. Remember we have to declare variable only once with the same name.
I hope you can catch the error now.

thank you. I don’t understand very well though. Did I not assign the value of a to b here: var b = var a;?

And from what I can see the vars have only been declared once: var a; and var b; ?

By using var b = var a, you are declaring the variable a and b again. I hope you can catch the error this time. Read the problem statement and my explanation carefully. Its very simple error.

2 Likes

Now, I see. Thank you for your help.

1 Like

freeCodeCamp lesson are very well plan, I hope you are native english speaker. Read each line carefully and understand every word. You will get it.

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.