Basic JavaScript - Assigning the Value of One Variable to Another

Tell us what’s happening:
Why is this not working??

Your code so far

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

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



Your browser information:

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

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

Link to the challenge:

The instruction: " Assign the contents of a to variable b ."

The variable a is declared, and the number 7 is assigned.
The variable b is only declared. In order to assign some value to it, the challenge asks you to make it equal to ‘a’ by assigning ‘a’ to it.
Don’t use the var keyword here (the variables are already declared), only the variable names. The ‘b’ should be on the left side of the ‘=’ operator.

Consider again the given example:

var myVar;
myVar = 5;
var myNum;
**myNum = myVar;**  (what is 'a' and what is 'b' in your case?)
1 Like

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