let abc = 'abcdefghijklmnopqrstuvwxyz'; let ran = ~~(26 * Math.random()); let a_z = abc[ran];
In one line of code:
let a_z = 'abcdefghijklmnopqrstuvwxyz'[~~(26 * Math.random())];
Alternatively, for uppercase:
let A_Z = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'[~~(26 * Math.random())];
Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.