Last active
June 26, 2018 07:17
-
-
Save ndabAP/613924c2bba0deae967ceb8f8787b320 to your computer and use it in GitHub Desktop.
Random alphabetical string with JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @see {@url https://stackoverflow.com/questions/30452263/is-there-a-mechanism-to-loop-x-times-in-es6-ecmascript-6-without-mutable-varia#answer-30452949} | |
*/ | |
const times = x => f => { | |
if (x > 0) { | |
f() | |
times (x - 1) (f) | |
} | |
} | |
let hash = '' | |
times (3) (() => hash += String.fromCharCode(97 + Math.floor(Math.random() * 25))) | |
console.log(hash) // e. g. fkq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment