"Old enough to play"

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?

1 Like

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.

1 Like

@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 Likes

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!”);
}

1 Like

That is complete and utter garbage.

1 Like

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

2 Likes

// 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

2 Likes

It wants age

1 Like

@staciesimambo see also

1 Like

It helped me very much. Thank you @gracie017

2 Likes

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.

1 Like

Thank you so much! Let me see if it works

1 Like

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

1 Like

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.

1 Like

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

Hope it helps!

1 Like

Ok ill try thx for the help

1 Like

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

1 Like

HI the error come from here

if (age<10)

your should check if age is great than 13 .

Spoiler
if (age>13)

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

2 Likes

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

1 Like