期望一个标识符,却看到了'else'

Expected an identifier and instead saw 'else'

本文关键字:else 标识符 一个 期望      更新时间:2023-09-26
if(userThree === "Yes");
{
console.log("You go to your car and realize you've left it unlocked.);
}
else;
{
console.log("You continue to eat your meal.");
}

我把这个放到JS Bin上,但它继续说:期望一个标识符,却看到了'else'。期望一个赋值或函数调用,却看到一个表达式。

我不知道如何修复这个

在你的第一个console.log中,你的字符串没有被完全引用:

"You go to your car and realize you've left it unlocked." // <- string needs to end with a quotation mark

同样,在这些位置(见下文)使用分号也不会得到你想要的结果。

if(userThree === "Yes"); <-
else; <-

下面一行缺少一个结束双引号:

console.log("You go to your car and realize you've left it unlocked.);
//                                               Here--------------^

还需要去掉ifelse后面的分号