简体   繁体   English

预期标识符,而不是'else'。 在JavaScript中缺少分号

[英]Expected an identifier and instead saw 'else'. Missing semicolon in JavaScript

This is the code i have atm. 这是我的代码。 It Say "Expected an identifier and instead saw 'else'. Missing semicolon." 它说“预期标识符,而是看到'其他'。缺少分号。” for the "else" in - 对于“其他” -

if(fight === "Fight");
{
    alert("You Fought The Pikachu And Won!");
}
else
{
    alert("You Ran From The Pikachu And Got Away To Saftey");
}

Should be obvious from the error message, but an if statement does not end with a semicolon. 从错误消息中可以明显看出,但if语句不以分号结尾。

replace 更换

if(fight === "Fight"); // <- SYNTAX ERROR
{
    alert("You Fought The Pikachu And Won!");
}
else

with

if(fight === "Fight")
{
    alert("You Fought The Pikachu And Won!");
}
else

As for shortening, you could start be removing the uneccessary switch / case -> http://jsfiddle.net/adeneo/naNk9/ 至于缩短,你可以开始删除不必要的开关/案例 - > http://jsfiddle.net/adeneo/naNk9/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM