Code your own Adventure module help!


#1

So this is my code, to check the user's age, but whenever I try and save it, I get a dialog box saying:

I haven't checked for the user's age? What am I missing? Example of my code below:

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

if(age>=18)
{
console.log("you are ready");

}
else
(age<18)
{
console.log("You are not the required age!");
}

`


#2

Hi the else statement doesn't need of the condition


#3

When coding an else statement, you shouldn't have a condition. If there is a need of a second condition, you use 'else if'. The else statement is made if all other conditions haven't been met.


#4

your code is-
confirm("Are you ready to play?");
var age = prompt("What's your age");

if(age>=18)
{
console.log("you are ready");

} 
else
(age<18)
{
console.log("You are not the required age!");
}

you don't need to write (age<18)
becuase if "(age>=18)" is true then it must be "(age<18)"
ok???
@bitmaster28787
Any quesion?


#5

@bitmaster28787

I think in the instructions, we were told to test if the user's age is less than 13 years old???