Math对象随机数方法 random()返回一个随机小数 0 =< x < 1
获取随机整数直接上公式
function getRandom(min,max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
console.log(getRandom(1,10))
Math对象随机数方法 random()返回一个随机小数 0 =< x < 1
获取随机整数直接上公式
function getRandom(min,max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
console.log(getRandom(1,10))