下面的脚本工作正常,但我只是不明白它是如何工作的,尤其是以下部分:Math.floor(Math.random() * 101);。有人可以解释一下整个脚本是如何工作的。谢谢你。
<SCRIPT LANGUAGE="Javascript">
var num = Math.floor(Math.random() * 101);
function guessnum() {
var guess = document.forms["form1"].num.value;
if (guess == num) {
alert("Great you Guessed! How did you know that?");
}
if (guess < num) {
alert("No your number is too low!");
}
if (guess > num) {
alert("No your number is too high");
}
}
</SCRIPT>