2.Code your own adverture (again)


#1

Please tell me what is wrong with this... because it wont work and im getting a bit stressed!

var age = prompt("you need to be over 13 to play this game, are you old enough?");

if("age"<13);

{
console.log("allowed to play but i take no responsibility");
}
else
{
console.log("playon");
}


#2

If i change
"age"<13

to just

age<13

I still have the same issue BTW.
SyntaxError: Unexpected token else


#3

You have to remove the ' ; ' at the end of the if conditional


#4
if(age<13) {
    console.log("allowed to play but i take no responsibility");
}
else
{
    console.log("playon"); 
}

#5

THANKYOU!!! That was killing me!


#6

Happy to help ^_^ Make sure you remember that ' ; ' is a statement (line) terminator, so using it at the end of the if conditional immediately terminates it, instead of the control going into it.