js中两个数之间的随机数
点击查看代码
function rangeOfRandomNumbers(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
}