我是编码的新手,我无法弄清楚我做错了什么。每次我尝试编写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!")
}
答案 0 :(得分:6)
更改此行:
if (help === yes)
到此:
if (help == "yes")
由于yes
不是变量。
答案 1 :(得分:3)
if (help === 'yes')
yes
是一个字符串,必须引用