24. Variables


#1

How am I getting a SyntaxError: Unexpected token var?

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


#2

You are mixing up several statements. The function console.log() expects a value to print, but you gave it an initialization statement. You should initialize myAge before you print it to the console.


#3

it's weird cause it auto starts the example code as: console.log(myAge);


#4

What is the correct way to type the answer code to progress?


#5

The purpose of the program is to print the value of the variable myAge, so console.log() accepts myAge as an argument. However, you must initialize a variable before you can use it.


#6

Sorry, I can't tell you the program.


#7

How would you write your own answer?


#8

Well, you would need to initialize myAge first. Use the var keyword and give myAge a default value.


#9

got it, thank you.
var myAge = 30
console.log(30);