Syntax Error: Unexpected Keyword 'else' ---- HELP!


Syntax Error: Unexpected Keyword 'else'

// Check if the user is ready to play!
confirm("Press 'OK' to play the game!");
var age = prompt("How old are you?");
if (age<13)
    console.log("sorry, your not old enough to play!");
    console.log ("Awesome! Let's Play!");

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 Justin Bieber on stage?");

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.'");

var feedback = prompt("How was my game? Rate it 1-10!");

if (feedback >= 8);
    console.log("Great! Thanks for playing!");
    console.log("Awe, I'll try harder next time!");


The problem is the last else statement I believe...


this line:

if (feedback >= 8);

that is one very dangerous semi-colon, it prevents the if condition from working properly


Thankyou, I figured it out shortly after posting the issue. Thankyou for your help :slight_smile:


Why does it prevent it from working properly?
BTW, what is the meaning of the semi-colon after a command?

Thank you!



Semi-colons are periods in Javascript.


like @lance347 says, there are periods, but your if statement wasn't finished yet.