麻烦老师检查一下代码
来源:4-9 编程练习
慕虎0507412
2019-02-11 02:11:55
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Math.random()</title>
</head>
<body>
<script>
function getRandom(m,n){
var choise=n-m+1;
return Math.floor(Math.random()*choise+m);
}
var num=getRandom(0,9),a=0;
console.log(num);
while(a!=num){
a=prompt("请输入你猜的数字");
if(a>num){
alert("输入的数字大了");
}else if(a<num){
alert("输入的数字小了");
}else if(a=num){
alert("恭喜你猜对了");
break;
}
}
</script>
</body>
</html>1回答
同学,你好。效果实现没有问题,代码也很规范,加油,继续努力。
祝学习愉快!
相似问题