If else statement


#1



I don't understand what i am doing wrong
There was a problem with your syntax.


if(condition)
{
    userAnswer = prompt("You and Bieber start racing. It's neck and neck! You win by a shoelace!")
}
else(no)
    userAnswer = prompt("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")
}
condition: you should evaluate is your "age" more than, 13


#2

The else statement doesn't need a condition. It's saying that anything else that is not specified by the if statements will run here. Does that make sense?


#3

I have tried that but it doesn't do anything


#4

Is this your full code because you didn't make a variable called condition before you made this if/else statement.


#5

okay i will try that and see if this works


#6

Also remove this part:

I think this is just telling you what to do.


#7

okay I just tried that and it still says syntax error


#8

Can you post a link to the exact lesson your on?


#9

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


#10

Can you show your full code or is this it?


#11

//Here's your answer
confirm("START");// Check if the user is ready to play!
var age = + prompt("What's your age");
if (age >= 13) {
console.log("You are allowed to play, but we take no responsibility for that");
}
else {
console.log("You are too young to play this game! Go to school");
}


#12

age>=13 is actually your condition in if/else statement


#13

okay thank you very much


#14

prompt is a pop up that asks a user for any input (string or number)


#15

this isn't for the correct one this question is for the story heats up


#16

you assign your user answer (in prompt) to your var, that is called age, and then you evaluate it


#17

You're not supposed to post the full answer. On the Q&A forums we are here to help each other solve our problems and learn from our mistakes. We are not here to give short cuts and "cheat" if that's what you want to call it.


#18

I've just followed your link


#19

Sorry, I'm new here, I've only asked questions, I'll try better in explaining things


#20

it is the second if/else statement.