24. Variables


How am I getting a SyntaxError: Unexpected token var?

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


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.


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


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


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.


Sorry, I can't tell you the program.


How would you write your own answer?


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


got it, thank you.
var myAge = 30