我正在做一个课程课程,这需要一个制作程序,询问学生每天要学习多少小时,但是我无法获得提示命令在这些JavaScript系列中工作:< / p>
<html>
<body>
<script>
var studiedhours = prompt("How many hours do you study a day?");
if (studiedhours <= 0) { alert{"Sorry, you must enter a number between 0 and 24"}
}
else if (studiedhours >= 5) {
alert("Well Done! \n Keep it up!")
}
else if (studiedhours >= 24) {
alert("Sorry, there is only 24 hours in a day, you entered an invalid number")
}
else {
alert("You should study more!")
}
</script>
</body>
</html>
什么阻止提示命令工作?
答案 0 :(得分:0)
您的代码中存在语法错误。
在这一行中使用括号,而不是大括号。
alert{"Sorry, you must enter a number between 0 and 24"}
到
alert("Sorry, you must enter a number between 0 and 24")
希望这会有所帮助。