gpt4 book ai didi

javascript - 涉及 "else if"且缺少操作数的错误

转载 作者:行者123 更新时间:2023-12-02 17:42:02 26 4
gpt4 key购买 nike

我正在用 JavaScript 制作一个选择你自己的冒险风格的游戏,在本节中:

evade = prompt("Go out of your way to avoid them, just in case? (y/n)");
if(evade = "y");
{
alert("Even though you went well out of your way and changed course multiple times,the two men are still with you.");
alert("Your stalkers have kept the same pace and distance the entire time but do not seem to be interested in confrontation.");
}
else if(evade = "n"); {
alert("the two men have caught up with you.");
alert("as you turn the corner, they sweep you off your feet and stab you");
alert("you are dead");
}

我在第 9 行收到错误“缺少操作数”(else if(evade = "n"); {),但我无法弄清楚。请帮忙!

最佳答案

在比较中使用=== 只是一个赋值。

然后不要在 ifelse if 之后放置 ;

关于javascript - 涉及 "else if"且缺少操作数的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22123161/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com