SyntaxError:意外的标记else(我在代码中找不到错误)

SyntaxError: unexpected token else (I can not find the error in my code)

本文关键字:代码 找不到 错误 意外 else SyntaxError      更新时间:2023-09-26

我遇到语法错误,我不知道我做错了什么。我已经将可能的错误缩小到这段代码中,但在那之后,它的确切位置变得模糊了。我很确定这和最后一个有关。(顺便说一句,我是一个初学者,如果这是一个非常容易的错误,我很抱歉。)

if(finishAnt == "yes") {
                console.log("congratulations you have killed the aint eater!")   
            }
            else if(finishAnt == "no") {
                console.log("You run away and barley make it, you are badly hurt");
                } else {
                    console.log("sorry thats not an option")
                }
            }

您有一个额外的}

校正为

if(finishAnt == "yes") {
   console.log("congratulations you have killed the aint eater!")   
}
else if(finishAnt == "no") {
    console.log("You run away and barley make it, you are badly hurt");
} else {
    console.log("sorry thats not an option")
}