Got keyword else


#1

console.log("You are at a 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?",'yes');
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! Beiber shakes his head and sings 'I set a pace, so I can race without pacing.'");
}

I get problem with syntax error got keyword else. I don't know what is going on. If I delete the else word, the program runs and then it says forgot to add else. I add else and it gives me the error. Please help me.


#2

I think I see the issue. I believe you have a semicolon where it should not be. Remove the semicolon at the end of this line and I believe your code will work fine.


#3

As and addition to what @pdmuse said, here is an explanation what happens: