Old enough to play?


#1

prompt("are you ready to play?");
confirm("I am ready to play!");
var age = prompt("what is your age");
if(age is less than 13);{
console.log("you are allowed to play but we take no responsibility");}
else{
console.log("play on my bud");}

It says syntaxerror: expected ')'


#2

if(age is less than 13);{
          ^            ^
          1            2

Two things wrong in this if statement.

1:

(age < 13) // Not (age is less than 13)

2: The semi-colon " ; " , is an "End of Statement" expression. Meaning after you put it at the end of the if statement it will tell the code to skip over the expression within the opening and closing brackets " { ... } ". Just get rid of the semi-colon at the end of the line and you should be good to go :smiley:


#3

thank you for your help


#4

confirm("I am ready to play");
var age = prompt("What's your age");
if(age < 13)
{
console.log("You may play, but I take no responsibility);
}
else
{ // "otherwise"
console.log("Play on!");// do this code
}

Why do I keep getting a syntax error for this?


#5

Hi Man,

I had the same problem and after many attempts solved it..
when you enter - var age = prompt('what's your age'); make sure that the 's in the word 'what's is Apostrophe.
I have entered it without any Apostrophe like ('Whats your age'); and it works perfectly
Try this and i wish it will work..
Good luck !!


#6

Hi you also dont have a " on the end of your line console.log("You may play, but i take no responsibility");


#7

Someone here help with this I tried to do what all of you said earlier in this chat-room but it still wont work plz help


confirm("I am ready to play!");
var age = prompt("Whats your age");
if(age is < 13)
{
console.log("NO")
}
else
{
console.log("Play ON")
}

:disappointed:


#8

Don't write "is" in your if statement test. Just write "if(age < 13)"


#9

Ok I will try that :expressionless:


#10

Your a legend!! Thanks :smiley: