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


#1



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


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!");
}
else
{
    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!");
}
else
{
    console.log("Awe, I'll try harder next time!");
}


#2

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


#3

this line:

if (feedback >= 8);

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


#4

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


#5

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

Thank you!


#6

@kjimbin,

Semi-colons are periods in Javascript.


#7

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