I need help on code your adventure lesson 2


#1

Why does it says "syntax error:unexpected identifier"?

here is the code i wrote

// Check if the user is ready to play!
confirm('Are you ready to play');
var age = prompt("What's your age");
if(age is less than 13);
{
    console.log("You are allowed to play but I dont take full responsibility");
}
else
{
    console.log("Get ready to play your best game");
}
AND THESE IS THE INSTRUCTIONS:
Under the existing code, declare a variable age.
Make age equal to prompt("What's your age");. See the example above.
Then write an if/else statement. If age is less than 13, use console.log to tell the user that they're allowed to play but you take no responsibility.
Else, use console.log and give them an encouraging message to play on!


#2

less than operator <
so here
if(age< 13); //

and remove ; after if condition.

check Comparison operators
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Expressions_and_Operators


#3

i am getting the same thing, here is what i got:
// Check if the user is ready to play!
confirm("Are you ready?")
var age = prompt("What's your age");
if(age is < 13)
{
console.log("you may play but i take no responsibility")
}
else
{
console.log("we will get there")
}


#4

Why using "is"? You should only use operators.


#5

my reading is not that great, i am learning new skills after a long recovery from serious head injuries.


#6

Oh! You will be better soon. :slight_smile:

We learn from mistakes and that's not bad. Keep it up and keep trying. You will be an expert one day.

We are here to learn and help. :slight_smile:


#7

thank you guys ■■■■ i just follow the writing on the instruction , i forgot the basics
much love!


#8


What is wrong in my code ? please help me ...


#9

what the error massaage you are getting?
missing ) after argument list
so you should think about that

in your code
else statement
console.log("hurry ! go ahead"!);

! shouldn't be inside of " " ?


#10

I tried as you said even then it is shown the error message
"SyntaxError: missing ) after argument list"


#11

Finished this exercise and this is the code ...
var age = 12;
var age = prompt("what's your age");
if(age < 13){
console.log( "you're allowed at your own risk!");
}
else{
console.log( "hurray go ahead!");
}


#12

remove this line

var age = 12;

its like you have extra code.because in seocnd line you are asking user what's your age
the value will be set to the variable age.
for example:
if user input 15 then it'll be like

var age = 12;
var age = 15;

First one is not valid now.


#13

A post was split to a new topic: I get: ReferenceError: promt is not defined


#14

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