注:PC端预览请使用浏览器模拟移动端预览查看最佳展示效果
function rnd(n, m){ n=1;//最小随机数 m=100;//最大随机数(概率范围最大值) //最大数数不超过最大随机数 var ransluck = [50,60,65,70,75,80,85,90,95,100];//概率为比自己小的第一个数之间的差 var randoms = Math.floor(Math.random()*(m-n+1)+n); if(randoms<=ransluck[0]) { var random = 1; } else if(randoms<=ransluck[1]) { var random = 2; } else if(randoms<=ransluck[2]) { var random = 3; } else if(randoms<=ransluck[3]) { var random = 4; } else if(randoms<=ransluck[4]) { var random = 5; } else if(randoms<=ransluck[5]) { var random = 6; } else if(randoms<=ransluck[6]) { var random = 7; } else if(randoms<=ransluck[7]) { var random = 8; } else if(randoms<=ransluck[8]) { var random = 9; } else if(randoms<=ransluck[9]) { var random = 10; } alert(randoms); alert(random); return random; }