Hi. I don't get it. Why we can't just put a value of " 7" at the very beginning. Also, how can var b=a if b is 2?

You could do that as well but what this exercise is intended to do is to make you understand how the assignment operator works.

var a=1;
var b=a; //it assigns to the variable b the same value as the variable a

control.log(b); // prints 1

var a=1;
var b=1;

control.log(b); // prints 1

As you can see we get the same result.

1 Like

You could definitely put var a=7 at the top, however, per the exercise instructions, you need to do it after the lines you’re being asked to.

Now regarding your second question, a and b are variables, that means, their value can be changed. Part of the exercise is to understand that you can change these values and how to do this with the assignment operator. Several programming languages also have the concept of a Constant, which is an expression that can never be changed. So if you would do Constant b = 2, even if you later do b = a or b= 3, the compiler will fail. But this is for future lessons.

For now please bear in mind that you cannot dovar b = a again. Using var means you’re declaring a variable. You’ve already declared b earlier, so doing it again may cause you errors. Just do a single b = a like you did with a = 7.

1 Like