2. Old enough to play?


#1

// Check if the user is ready to play!
confirm("Are you ready to play?");
var age = prompt("What's your age");
if (age < 10) {
conosle.log("You are not old enough to play this game!");
} else {
console.log("I hope you are ready to play!");
}

this is my code it says Oops, try again. It looks like you didn't check for the user's age. what is wrong with it?


#2

You are supposed o use the same responses the course offers, which can be a pain. Also you checked if the age was smaller than 10 , when you're supposed to check whether their age is smaller than 13.


#4

hi!
your conditional clause is bad defined and after " if" your var need quotes.
// 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 not old enough to play this game!")
}
else {
console.log("I hope you are ready to play!")
}

this code is good for me


#5

I did how you say here above but it still does not work: ' ( its been one day that I 'm stuck


#6

var age = prompt("What's your age");
confirm("estoy peparado para jugar");
if ("age"<13){
console.log("no puedes jugar")
}
else {
console.log("puedes jugar")
}


#7

confirm("Are you ready to play?");
var age = prompt("What's your age?");
if ("age"<13)
{
console.log("Sorry, you are not old enough to play!")
}
else
{
console.log(OK, you are old enough to play")
}

I get -- SyntaxError: missing ) after argument list


#8

Age DOES NOT go in " " as your not testing a string, you want the users input.

@danfitz1

Take age out of quotes (age <13);

You're missing a " before OK.

Make sure you're using the same text and punctuation given in the instructions


#9

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!")
}


#10

Age shouldn't be in quotes, that making it a string. It will always return false because it is comparing 3>13 rather than the user input of age.
if(age < 13) {


#11

" confirm("I am ready to play!");
var age = prompt("What's your age");
if(age < 13);
{
console.log("You are too young to play this game!");
} else {
console.log("Let's begin");
}
"

Hi this is my code and it's not going through for some reason. Can someone please help!


#12

"if(age < 13);"
don´t have ";" at the final .
when you open an if clause you only put "{"
put :
confirm("I am ready to play!");
var age = prompt("What's your age");
if(age < 13){
console.log("You are too young to play this game!");
}
else {
console.log("Let's begin");
}