【发布时间】:2015-06-26 04:23:38
【问题描述】:
var temp = 110;
for {
temp-=1
if (temp >= 90) {
console.log("Today's temperature is "+temp+"! "+"Lets go play ball")
} else {
console.log("Today's temperature is "+temp+"! "+"It is too hot today to ball!")
}
}while (temp > 90)
请查看我的 sn-p。由于我已经检查了括号,由于某种原因它不会运行说明一些括号错误。
【问题讨论】:
-
你用错了。替换它来做。
-
用
do替换for -
我有一个问题要问你!如果您要求用户提示,则不应使用 while 循环,因为这将使您的循环永远持续下去。
-
我明白了。对不起我的无知。我只是想看看如何实现它......迟早我会自己意识到让用户提示代码是一个错误。 =\谢谢你的建议!
标签: javascript loops if-statement