SyntaxError: Unexpected keyword 'else' Please help


#1

Hi guys, I keep getting the SyntaxError message in my console log however I don't see anything wrong with my code. Can you please help? Here is my code:

console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");

console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'")
var userAnswer = prompt ("Do you want to race Bieber on stage?");

confirm("Are you ready to play?");

var age = prompt ("What is your age");

if ("What is your age" < 13); {
console.log ("You are allowed to play but we will not take any responsibility");
} else {
console.log ("Play on!")
}
if (userAnswer === "yes");{
console.log ("You and bieber start racing. It's neck and neck! You win by a shoelace!");
} else {
console.log(" Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'");


#2

After your condition you shouldn't have a semi colon before the curly bracket.. (on both your if statements)
This (condition);{ should be: (condition){


#3

Just to add to this answer I also highly, highly recommend you check out this awesome guide on this topic. :slight_smile:


#4

Thank you both for elaborating on this topic. It now says correct and this was the end result:


#5

The answers I put were:
Answer 1: yes
Answer 2: ok
Answer 3: 10


#6

Does the screenshot show that it functions properly now?


#7

I think so :question: :slight_smile:


#8

Well, nontheless you gave me a really fast answer! Thanks! :grinning:


#9

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