How I can change "a" in "b" with "="?

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

Your code so far

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

// Only change code below this line

Your browser information:

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

Challenge: Assigning the Value of One Variable to Another

Link to the challenge:

Hi. I had a look at your challenge. The original code looks like this:

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

// Only change code below this line

What you did was change the code above the line that says: ‘Only change code below this line’.

While that is not a crime :wink: it does break the code.

By changing the 2nd line, as you did, the initial value (of 7) is not assigned to “a”.
Which means, “a” is ‘undefined’. That means, it has no value.

It’s like painting a car, where, the owner of the car wants a red roof.
The car owner also wants the color of the doors to be the same as the color on the roof.
The given code says:
the car has a roof (var a;)
make the roof red (a = 7;)
the car has doors (var b;)

What they want you to do is, make the doors the same color as the roof (in this case: red) (in the code: 7)

What your code does is … make the color of the doors equal to the color of the roof. But your code has replaced the line that says- the roof is red (a = 7)
Now, the guy wanting to paint the car does not know if it should be yellow, green, white, blue, or red.
So, if you Reset your code and try again, pls leave the 1st 3 lines unchanged.
Then, add a line below the last line- the line that says, ‘Only change code below this line’

That is when you can say
b = a (make the doors same color as the roof).
By that time, the painter knows the owners preference in color, namely, red. (And the code has already assigned the value 7 to the variable “a”).
In JavaScript, to assign a value to a variable, we use the “=”

Older languages, like Pascal, used “:=”, but a lot of the modern languages just use “=” to assigna values.

Hope this helps to understand the concepts. If not, no worries, just ask for clarification and I’ll try again.


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