<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script type="text/javascript">
console.log(Math.ceil(12.9))//返回的是大于该数字的最小整数
console.log(Math.floor(12.9))//返回的是小于该数字的最大整数
console.log(Math.round(12.9))//将数进行四舍五入
console.log(Math.max(12,9,62,16))//求最大值 两个数及多个数的最大值
console.log(Math.pow(2,9))//2的9次方
console.log(Math.random())//随机产生0-1之间的任意数字[0,1)
console.log(Math.floor.random()*11)
</script>
</body>
</html>
2.<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<input type="text" name="result" id="result">
<input type="button" id="cai" value="猜数字">
<script type="text/javascript">
//猜数字游戏
var num = Math.floor(Math.random() * 11)
console.log(num)
document.getElementById("cai").onclick = function() {
for (i = 1; i < 5; i++) {
var result = Number(document.getElementById("result").value)
if (result == num) {
alert("你赢了")
break
} else if (result > num) {
alert("你输入的数太多")
i++
continue
} else if (result < num) {
alert("你输入的数太小")
i++
continue
}
if (i >= 5) {
console.log("你输了")
}
}
}
</script>
</body>
</html>