Problem with part 2


#1

Hi all, I have just tried to finish part 2 of "Code Your Own Adventure".

I followed all of these instructions:
Under the existing code, declare a variable age.
Make age equal to prompt("What's your age");. See the example above.
Then write an if/else statement. If age is less than 13, use console.log to tell the user that they're allowed to play but you take no responsibility.
Else, use console.log and give them an encouraging message to play on!

I typed this code: // Check if the user is ready to play!
confirm("I am ready to play!");
var age = prompt("What's your age");
if(age is less than 13) {
console.log("Be aware!");
} else
{
console.log("Play Around");
}

When I push the button "Save & Submit Code", I get this error:

SyntaxError: missing ) after condition

Does anyone know what the problem might be? Or can anyone help me maybe?

Thanks in Advance!


#2

if/else syntax:

if (condition) {
    block of code to be executed if the condition is true
} else { 
    block of code to be executed if the condition is false
}

Condition is an expression that returns boolean value. So, you need to use comparison operators:

>	greater than	x > 8	 -> false
<	less than	    x < 8	 -> true
>=	greater than or equal to	x >= 8   -> false
<=	less than or equal to       x <= 8   -> true

#3

It worked!

Thanks a lot mr. Matsevych!


#4

if(age < 13){
console("whatever you want it to say if true");
}else{
console("what to say if condition is false");
}


#5

JS doesn't have console, should be console.log.


#6

Hi i did var age = prompt("what's your age");
if(age is less than 14)
consle.log("be aware!");
}else //executed if the condition is false
{
consle.log("play around");
}
but it said SyntaxError: Unexpected identifier


#7