//得到一个指定范围内随机整数
function getRandom(min, max) {
//Math.random() [0,1)
//Math.random()* (Max-min) [0,Max-min)
//Math.floor(Math.random() * (Max-min)+min [min,Max]
return Math.floor(Math.random() * (max - min) + min);
}
console.log(getRandom(3, 90));
标准库(Math)——得到一个指定范围随机整数
于 2024-01-05 17:13:43 首次发布