var age = Number(prompt("How old are you?"));
if(age >= 13) {
console.log("You are old enough!");
alert("You Are old enough!");
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?");
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.'");
}
} else {
console.log("Sorry, You Are Not old Enough :(");
alert("Sorry, You Are Not old Enough :(");
}
我越來越:JavaScript的菜鳥級語法錯誤
SyntaxError: Unexpected token 'else'
如果有人可以幫助我,將是巨大的:)
變化'如果(userAnswer) 「是」;''來,如果(userAnswer == 「是」){' – Bart
@SamuelLiew您剛纔編輯自己的錯誤離開這個問題?沒有人知道上下文了。 – A1rPun