Math.random随机函数
包含0 ,不包含10
var a = Math.random() * 10;
console.log(a) //0~9
包含1,包含10
var b = parseInt(Math.random() * 10 + 1);
console.log(b); //1~10
包含min , 不包含max
function getRandom(min,max) {
return Math.floor(Math.random() * (max - min)) + min;
}
包含minx , 也包含max
function getRandom(min,max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}