gpt4 book ai didi

javascript - if/else 语句不起作用?

转载 作者:行者123 更新时间:2023-12-02 06:36:06 25 4
gpt4 key购买 nike

我是编码新手,我不知道自己做错了什么。每次我尝试写一个 if/else 时,它​​都会工作到语句的程度,然后它就不会工作了。

这是我写的:

alert("welcome to chloe's quiz show!")
var name = prompt("contestant, what is your name?")
var help = prompt("is this your first time playing? type 'yes' or 'no'.")
if (help === yes){
alert("the game is easy! all you have to do is type the letter that corresponds with the correct answer. then press 'ok'.")
confirm("lets get started!")
}
else{
confirm("lets get started then!")
}

最佳答案

改变这一行:

if (help === yes)

为此:

if (help == "yes")

因为 yes 不是变量。

关于javascript - if/else 语句不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18605087/

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