const symbols = '~!@#$%^&*()_+{}":?><;.,';
let list = [
String.fromCharCode(Math.floor(Math.random() * 26 + 65)),
String.fromCharCode(Math.floor(Math.random() * 26 + 96)),
String.fromCharCode(Math.floor(Math.random() * 10 + 48)),
symbols[Math.floor(Math.random() * symbols.length)]
]
let str = ''
for(let i = 0; i < 8; i++) {
str += list[Math.floor(Math.random() * 4)]
}
console.log(str)
本文由mdnice多平台发布