Can someone help me for question 24 pls


#1

They said "Create a variable called myAge and type in your age" and they give me and early code like this
console.log(myAge); what i did is like this,

console.log (var myAge === 44 ) ;

and it came out like this SyntaxError: Unexpected token var.

It Goes Error When you put inside of the console you supposed to put outside the console like this

console.log (var myAge);
var myAge = 30;

:sweat_smile:


#3

var is used declare what is essentially a namespace. Once we declare a variable, we never have to (or need to) declare it again.

var myAge;

This variable will remain in memory until the end of the session. We cannot remove it once we declare it. Nor can we change its name. As yet, it has no associated object, so is undefined.

console.log(myAge);    // undefined

We define a variable by the object we assign to it. Now that the variable exists, we never write var with it again.

myAge = 19;
console.log(myAge);    // 19

When we declare AND define a variable in the same line we always use an assignment operator,=.

var myAge = 19;

The === is an identity comparison operator, and never used to make an assignment.


#4

Ok Thanks Bro :heart_eyes:


#6