javascriptランダム文字列参照([A~Z],[a~z],[0~9])
378 ワード
function ranNum(l) {
return Math.floor(Math.random() * (l[1] - l[0])) + l[0];
}
function r(len) {
var s = "",t;
for (; len > 0; len--) {
t = ranNum([[65, 91], [97, 123],[0, 10] ][ranNum([0, 3])]);
s = s + (t > 10 ? String.fromCharCode(t) : t.toString());
}
return s;
}
console.log(" ",r(10));