function RandomNum(len) {
    var rdmString = "";
    for (; rdmString.length < len; rdmString += Math.random().toString(36).substr(2));
    return rdmString.substr(0, len);
} 
console.log(RandomNum(10));

原文地址:https://course.51qux.com/1685.html