函数makeid(长度){ 让结果=“”; const characters=“ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789”; const charactersLength=characters.length; 让计数器=0; while(计数器<长度){ 结果+=characters.charAt(Math.floor(Math.random()*charactersLength)); 计数器+=1; } 返回结果; } console.log(makeid(5));