const s = ((n) => {
const alphanum = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let s = "";
for (let i = 0; i < n; i += 1) {
s += alphanum[~~(Math.random() * alphanum.length)];
}
return s;
})(n);
~~ is a faster way to call Math.floor().
Note that Math.random is not cryptographically secure.
Note that Math.random is not cryptographically secure.