<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Title</title>
<script>
function random(min, max) {
return b = Math.floor(Math.random() * (max - min + 1)) + min;
}
var b = random(0, 50)
for ( var i = 5; i >= 1 ; i--) {
var a = prompt('请输入一个数')
if (a > b) {
alert('你猜大了')
} else if (a < b) {
alert('你猜小了')
} else {
alert('你猜对了')
}
var x = i -1
alert('你还有' + x + '次机会')
}
</script>
</head>
<body>
<div>
</div>
</body>
</html><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Title</title>
<script>
function random(min, max) {
return b = Math.floor(Math.random() * (max - min + 1)) + min;
}
var b = random(0, 50)
for ( var i = 5; i >= 1 ; i--) {
var a = prompt('请输入一个数')
if (a > b) {
alert('你猜大了')
} else if (a < b) {
alert('你猜小了')
} else {
alert('你猜对了')
}
var x = i -1
alert('你还有' + x + '次机会')
}
</script>
</head>
<body>
<div>
</div>
</body>
</html>