首页 > 代码库 > js随机生成N位数

js随机生成N位数

function RondomPass(number){
    var arr = new Array;
    var arr1 = new Array("0","1","2","3","4","5","6","7","8","9");
    
    for(var i=0;i<number;i++){
        var n = Math.floor(Math.random()*10);
        arr[i] =arr1[n] ;
        //document.write(arr1[n]);    
    }
    
    val = arr.join("")
    //document.write(val);
    return val;    
    
}
RondomPass(8

适用于 随机生成密码