Help... Old enough?


#1

https://www.codecademy.com/en/courses/javascript-beginner-en-x9DnD/0/2?curriculum_id=506324b3a7dffd00020bf661#

I have completed this exercise however there is something that just bothers me. No matter the age I input the else message of "please enjoy the game" always shows whether age is greater than or less than 13. I can't figure out why it is doing this. Codeacademy says I have completed the exercise but I feel like I haven't until I can get only the correct message to play and not the other one.

 // Check if the user is ready to play!
confirm ("Hit ok if you are ready to play");
var age = prompt ("What's your age");
if (age <= 13) 
{
    console.log ("You may play, but I hold no responsibility. Please enjoy the game");
}    
else (age > 13); 
{
    console.log ("Please enjoy the game");
}

#2

if/else statement,
if must have a conditional expression but else goes without any conditional expression.

It simply catches all counter cases of if- block conditions so we don't need one for else.


#3

Ah, thank you very much


#4

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