<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>生成10个20-50之间的随机数</title>
<style type="text/css">
</style>
</head>
<body>
<script type="text/javascript">
function getRandomIntInclusive(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值,含最小值
}
var arr = [];
for (var i = 0; i < 10; i++) {
var num = getRandomIntInclusive(20, 50);
num = parseInt(num, 10);
arr.push(num);
}
console.log(arr); //生成10个20-50之间的随机数
</script>
</body>
</html>