function createCode(num){
var s= "";
for(var i = 0 ; i <num ;i++){
var three = parseInt(Math.random()*3)//3种类型(数字、大写、小写)
var temp;
if(three == 0){
temp = parseInt(Math.random()*(10)+48) //数字
}
else if(three == 1){
temp = parseInt(Math.random()*(90-65+1)+65) //大写
}
else{
temp = parseInt(Math.random()*(122-97+1)+97) //小写
}
s += String.fromCharCode(temp)
}
return s
}
console.log(createCode(4))