2

我是编码新手,我无法弄清楚我做错了什么。每次我尝试编写 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!")
}
4

2 回答 2

6

更改此行:

if (help === yes)

对此:

if (help == "yes")

因为yes不是变量。

于 2013-09-04T03:51:29.903 回答
3
if (help === 'yes')

yes是一个字符串,它必须被引用

于 2013-09-04T03:52:10.203 回答