随机生成指定两个数之间的数字数组
点击查看代码
//参数1和2表示生成的数字在两个数之间,参数3表示,几个数字组成的数组
function randomlyGeneratedArray(num1, num2, shuzhi) {
const randomss = (num1, num2) => {
let max, main
if (num1 > num2) {
max = num1
main = num2
} else {
max = num2
main = num1
}
//随机给出两个数之间的任意数
return Math.floor(Math.random() * (max - main)) + main
}
let arr = []
let a = 1
while (a <= shuzhi) {
arr.push(randomss(num1, num2))
a++
}
return arr
}