代码:
javascript
function code(){
let num1 = Math.floor(Math.random()*10)
let num2 = Math.floor(Math.random()*10)
let letter1 = String.fromCharCode(Math.floor(Math.random() * 26) + 97);
let letter2 = String.fromCharCode(Math.floor(Math.random() * 26) + 65);
var arr = [num1,num2,letter1,letter2]
var str = "";
for(var i=0;i<4;i++){
str += arr[Math.floor(Math.random()*(arr.length))]
}
return str
}
document.write(code());
效果图: