2. Old enough to play?


#1

Below is my code but it seems that there is some kind of error. It says "Syntax error: missing ) in parenthetical.

confirm("Are you ready?")
var age = prompt("What's your age");
if (("age" is < 13)) {
_ console.log(("you might play but you have to take responsibility"))_
} else
{ console.log(("Have fun, enjoy!"))


#2

You don't need quotes here around age, as it's a variable, and you don't need the word "is" because < means 'is less than', so it's not required.
You also don't need double brackets ((....)), only single (....), unless you're nesting function calls or doing complex equations or something.

Again, you don't need the double brackets.

Same here with the double brackets :stuck_out_tongue:

Your final code should look like this:

confirm("Are you ready?");
var age = prompt("What's your age");
if (age < 13) {
    console.log("You might play but you have to take responsibility");
}
else {
    console.log(("Have fun, enjoy!"))
}

Any questions? :slight_smile:


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.