第十二次作业
第十二次作业
这个作业属于哪个课程 | https://edu.cnblogs.com/campus/sdscfz/SF3 |
---|---|
这个作业要求在哪里 | https://edu.cnblogs.com/campus/sdscfz/SF3/homework/12980 |
这个作业的目标 | 第12次作业-Math对象猜数字游戏 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>zh</title>
</head>
<body>
<script>
function gao(min,max){
return Math.floor(Math.random()*(max-min+1)+min)
}
var min = 1,max = 10;
var random = gao(min,max);
while(1)
{
var x = prompt("请输入你猜的数字(1-10):");
if(x!=='')
{
if(x<random)
{
alert("猜小了!");
}
else if(x>random)
{
alert("猜大了!");
}
else if(x=random)
{
alert("猜对了!");
break;
}
}
else if(x===''){
alert("出错了!");
}
}
</script>
</body>
</html>