random()
生成一个随机数 0~1之间
var random = Math.random();
console.log(random);
随机整数公式
random = Math.floor(Math.random()*(m-n+1)+n)
例子
function getRandom(n,m){
var geshu = m-n+1;//整数个数
return Math.floor(Math.random()*geshu+n);
}
var random1 = getRandom(1,100);
document.write(random1);