2. Old enough to play?


#1

confirm("Ready to play?");
var age = prompt("What's your age");
if (age < 13);
{
console.log("You're not old enough to play!");
}
else
{
console.log("Play on!");
}

it says "SyntaxError: expected expression, got keyword 'else'"
What am I doing wrong?
Thanks


#2

Hi @imluckyluke

Delete semicolon after if condition line 3


#3

alright thanks @onepunch_man :+1:


#4

I'm on code your own adventure 2. Old enough to play. It keeps saying syntax error.In the little box it says SyntaxError: missing ) after argument list. Here is my code.

// Check if the user is ready to play!
confirm("Are you ready to play!");
var age = prompt("What's your age?");
if(age < 13) {

console.log(You are allowed to play but I take no responsibility for your actions.);

} else {

console.log("You are ready to play!");

}


#5

can you explain why you don't need a semicolon there?


#6

I am having an issue with this lesson too. Here is my code:

confirm("I am ready to play!");
var age = prompt("What's your age?);
if (age < 13)
{
console.log ("Sorry. You must be 13 or older to play.");
}
else
{
console.log("Great! Let's get started, shall we?");
}

I get the following error message:
"SyntaxError: unterminated string literal". Please help!


#7

I did this code and it worked. Try to base your code off of it and not just copy and paste, it helps with the learning process.
It will ask open a little question box which asks "Are you ready to play?"
If you hit OK then another box will open asking "What's your age?" and you have to type in someting over 13....obviously
confirm("Are you ready to play?");
var age = prompt("What's your age?");

if("age">13)
{
console.log("sorry but you must be older")
}
else
{
console.log("Great! You are all set then!")
}