JS 输出指定范围内的随机数

/* 自定义函数 */
function GetRandomNum(Min,Max){
    var Range = Max - Min;
    var Rand = Math.random();
    return(Min + Math.round(Rand * Range));
} 

/* 调用函数 */
var num = GetRandomNum(4,10);

猜你喜欢

转载自www.cnblogs.com/phpfensi/p/8984916.html