// Check if the user is ready to play!
var userAnswer = prompt("Do you want to race Bieber on stage?")
console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'")
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.'");
}
我正在努力做到这一点:如果userAnswer是,请打印出“你和比伯开始比赛。这是颈部和颈部!你用鞋带赢了!”
否则,打印出来:“哦不!比伯摇摇头,唱歌我设定了节奏,所以我可以在没有节奏的情况下比赛。
但它给我一个语法错误。
任何帮助表示感谢。
答案 0 :(得分:2)
你的问题在于这一行:
if userAnswer === "yes" {
您需要将该行更改为:
if (userAnswer === "yes") {
所以你的整个代码应该是:
var userAnswer = prompt("Do you want to race Bieber on stage?")
console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'")
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.'");
}
希望这有帮助。