<script>
function code(){
var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890"
var str1=" ";
//根据下标从str中取出对应的字符
for(i=0;i<4;i++){
//生成随机下标
var index=Math.round(Math.random()*str.length);
//取下标
str1+=str.charAt(index);
//下标对应的字符串
}
console.log(str1);
}
code();
</script>
12-23
1614
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)