Basic JavaScript - Assigning the Value of One Variable to Another

Tell us what’s happening:
Describe your issue in detail here.

Your code so far

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

// Only change code below this line

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

Why do we assign b = a instead of a = b?

If var b = 7 and a = b, doesn’t logic follow that a = 7?

I’m confused on why it’s b = a. We haven’t assigned any value to a.

Your browser information:

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

Challenge: Basic JavaScript - Assigning the Value of One Variable to Another

Link to the challenge:

But? We did?

You should not redeclare b or set b equal to 7 directly

You should not redeclare a or set a equal to the contents of b

This is the line you need. Try removing the other two.

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