function get(n){
var arr = [];
while(arr.length <n){
var num = Math.floor(Math.random()*10);
if(arr.indexOf(num) == -1){
arr.push(num)
}
}
return arr.join('')
}
console.log(get(4))
function get(n){
var arr = [];
while(arr.length <n){
var num = Math.floor(Math.random()*10);
if(arr.indexOf(num) == -1){
arr.push(num)
}
}
return arr.join('')
}
console.log(get(4))
本文标题:随机4位不重复验证码
本文链接:https://www.haomeiwen.com/subject/lbkcyctx.html
网友评论