【发布时间】:2023-02-06 20:15:32
【问题描述】:
非常简单明了我想做什么:
- 如果输入的是
0,说明他们没有输入数字 应该告诉你。 - 当输入
7时,它应该说你做对了。 - 任何其他的,它应该告诉你你弄错了。
但无论输入是什么,它都只输出“7 is correct”行,我无法弄清楚哪里出了问题。
<script type="text/javascript">
function problem2 ()
{
var number = 0;
var text=document.getElementById("output");
number = prompt("Enter a number between 1 and 10 please" , 0);
if (number = 0)
{
text.value = "You didn't enter a number!";
}
if (number = 7)
{
text.value = "7 is correct!";
}
else
{
text.value = "Sorry, ", input, "is not correct!";
}
}
</script>
<input type="button" value="Click here" onclick="problem2()">
<input id="output" type="text">
【问题讨论】: