Code your adventure


#1

May i know where i went wrong in this code?

confirm("Are you ready to play?");
var age=prompt("what's your age");

while(typeof age !="number")
{
age=prompt("enter correct age");

}
if(age<13)
{
console.log(" you're allowed to play but i take no responsibility.");
}
else
console.log("you can play");


#2

The prompt() function returns a string object.

console.log(typeof "13");    // string

For this exercise it is best to keep it as simple as possible so as not to create confusion for yourself. There is much yet to learn, so work with what you've been shown, thus far and give the tricky stuff a pass for now.

I would recommend removing this code, for the time being. It is not asked for or expected. Once this track has been completed you will be able to come back and improve on the code you created.

Remember to wrap all the blocks in an if statement.

else
{

}

#3

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