//生成 [1,max] 的随机数: max - 期望的最大值
random1(max) {
console.log(parseInt(Math.random() * max, 10) + 1);
console.log(Math.floor(Math.random() * max) + 1);
console.log(Math.ceil(Math.random() * max));
},
// 生成 [0,max] 到任意数的随机数,公式如下:
random2(max) {
console.log(parseInt(Math.random() * (max + 1), 10))
console.log(Math.floor(Math.random() * (max + 1)))
},
//生成区间 max - 期望的最大值 min - 期望的最小值
random3(min, max) {
// max - 期望的最大值
// min - 期望的最小值
console.log(parseInt(Math.random() * (max - min + 1) + min, 10));
console.log(Math.floor(Math.random() * (max - min + 1) + min))
}