"Old enough to play"


#1

confirm("I'm Ready!");
var age=prompt("What's your age");
if(age is less than 13)
{console.log("Play at your own risk");}
else
(console.log("Can't stop now!");}

Could somebody please tell me why the ■■■■ this code isn't working?


#2

This seems to be your problem.

There isn't anything in JavaScript called 'is less than'.

Also you forgot a curly brace on the else-statement.


#3

@cadecodes is right, there's no such thing as 'is less than' in javascript condition and you totally forgot the open curly brace on your else statement.

@lesserlight, instead of using the words 'is less than' , use the javascript operator '<'

Here's the whole blocks of codes

confirm("I'm Ready!");
var age = prompt("What's your age?");
   if(age < 13){
     console.log("Play at your own risk");
    }
else{
    console.log("Can't stop now!");
    }

Hope this helps.


#4

do if("age is less than 13") use quotation marks there. this how the code should look like// Check if the user is ready to play!
confirm("I understand confirm!");

var age = prompt("What's your age");

if("age is less than 13")
{
console.log("We will not take responsibility for your actions");

}
else
{
console.log("Have fun!");
}


#5

That is complete and utter garbage.


#6

Thank all of you. I got it to work!!!


#7

// Check if the user is ready to play!
confirm(" i am ready to play")
var Age =prompt("what's your age?");
if ("Age is less 13") {
console.log("seek parental permission");
}else {
console.log("lets play!")
}
its saying did you define a variable called age?
help


#8

It wants age......


#9

@staciesimambo see also


#10

It helped me very much. Thank you @gracie017


#11

Hi ! your problem is simple to solve.

The issue is here:

        if ("Age is less 13")

The computer dosen't understand the comparison with words, it already have a list pre-stablished for that. You need to use the symbols ( ===, < , >).

solution:

      if (Age<13)

No Quotes! since you re not typing a string.


#12

Thank you so much! Let me see if it works


#13

Oops sorry I thought that solution was for me... never mind :joy:


#14

confirm('Lets Play!');
var age = prompt('Whats Your Age?');
if (age<10) {
console.log('Are you sure your old enough?');
} else {
console.log('Lets Go!');
}

This is what I have written but it comes up with the error ...
'Oops, try again. It looks like you didn't check for the user's age.'

Even thought it does ask me and i put my age in? I'm confused please help.


#15

Hi ! i think you need to check your quotes (" ") since you're using (') , try replacing your (' ') for (" ") .

Hope it helps!


#16

Ok ill try thx for the help


#17

Unfortunately, it still came up with the error code, but hopefully ill figure it out. :slight_smile:


#18

HI the error come from here

if (age<10)

your should check if age is great than 13 .

Spoiler

if (age>13)


#19

oh. thanks thought it could be any age and just felt like ten. Didn't realize it would have to be 13. :joy:


#20

yeah instructions on Code exercise are very direct and wont accept something else unless 1) makes sense 2) they tell you you can put whatever you want ..mostly cause of reason #2 lol