Varuble qustion

Tell us what’s happening:
Describe your issue in detail here.
it says that I need to give a varle as 5 but also give a varable ab togather to eacal 7

**Your code so far

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

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

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14150.64.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.104 Safari/537.36

Challenge: Assigning the Value of One Variable to Another

Link to the challenge:

HI @wcondrey2024 !

I would reset the lesson because it looks like you made to many changes to the starter code that you weren’t supposed to.

Once you reset the lesson your starter code should look like this.

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

// Only change code below this line
WRITE YOUR CODE HERE :)

Make sure you are only adding code where you are supposed to.

As for your question, your task is to assign the contents of a to variable b .
Your answer should only be one line of code.

The way assignment works is that what is on the right hand side of the = will be assigned to the left hand side variable.

For example, if I wanted to assign my name to the variable called myName here is how I would do it.

//setup
var myName;

//Only change code below this line
myName = "Jessica"

You are going to apply that same principle to this challenge.
And remember to write your code in the correct place and your answer should only be one line of code.

Hopefully that helps.

I tried that but it gave me “Variable declaration expected.” what does that mean?

I would have to see your new code to see what is going on.
Can you paste it in the reply?

But you shouldn’t need to declare any variables.
That has been done for you.

Make sense?

b=7

var ab; this is what I have put
so should I say a=b

You don’t need to create a new variable called var ab.

And also you shouldn’t have this part either

This is the line you should pay attention to

You’re close here.
Right now your code says assign the contents of b to a
but the directions tell you to do the exact opposite and assign the contents of a to b.

Reset the lesson and only add this line but with a and b switched

1 Like