Help with Java #5

So, I just started coding recently, and I need some help with this lesson.

Your code so far

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

// Only change code below this line

var b;
b = 7;
var a;
a = b; // The variable 'a' is equal to b

Your browser information:

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

Challenge: Assigning the Value of One Variable to Another

Link to the challenge:

You should not re-declare a and b. That is not allowed.

Variables are created when we first “declare” them with the keyword var. As @JeremyLT pointed out, trying to re-declare a variable that already exists is an error. When we reassign variables we do not use the keyword var.

1 Like

Side note, this is Javascript, not Java. Its important to know so that you can Google the right questions :slight_smile:

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