Old Enough to play!


#1

I just typed:

// Are you Ready?
confirm("Of course");
var age = prompt("What's your age?");
if (age <= 13) {
console.log("You can play but We take no responsibility")
}
else (age > 13) {
consol.log("Welcome!")
}

And it gave me this:
Oops, try again. There was a problem with your syntax.

I saw a lot of threads but it did not work! :cry:


#2

Hi this part

else (age > 13) {
consol.log("Welcome!")
}

the else statement doesn't take any condition jut remove (age > 13)

if (condition) {

}
else {

}

#3

else is a default branch that takes no condition. If age is NOT less than or equal to 13, then it MUST be greater. That is not an assumption that needs testing. It is the only other outcome, hence, default.


#4

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