此JavaScript代码运行成功,但我认为它不会通过它的“其他”语句,因为它不打印它的控制台...为什么?或条件从未评估为真
i = 0;
for(var i=1; i<4; i++) {
var crazy = prompt("would you marry me?");
if(crazy === "Yes"|| "yes") {
console.log("hell ya!");
}
/* when it asks "will you marry me" and if the user says either "No" or "no", it does't print "ok..I'' try again next time". instead, it still says "hell ya !" */
else if (crazy ==="No" ||"no") {
console.log("ok..I'll try again next time !");
}
}
var love = false;
do {
console.log("nonetheless, I LOVE YOU !");
}
while(love);
条件的语法不正确。你需要再次检查变量。 '疯狂==='是'||疯狂==='yes'' –
它应该是'疯狂===“是”||疯狂===“是”。'||'yes''不是_compared_,而是评估为'true'。 – Xufox
嘿,非常感谢这么多家伙! –