var a = 'qwertyuiopasdfghjklzxcvbnm1234567890' var b = a.split('') var str = '' for (let i = 0; i < 4; i++) { str += b[Math.ceil(Math.random() * b.length - 1)] } console.log(str)
随机获取4位26个英文字母和数字组合的值(4位随机码)
于 2022-05-30 09:06:23 首次发布
var a = 'qwertyuiopasdfghjklzxcvbnm1234567890' var b = a.split('') var str = '' for (let i = 0; i < 4; i++) { str += b[Math.ceil(Math.random() * b.length - 1)] } console.log(str)