Last active
April 26, 2020 09:13
-
-
Save dhargitai/d2b95876dacbae4133f17bdfd6841b83 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let generateCode = (givenOptions = {}) => { | |
const {pool, length} = { | |
...{length: 3, pool: 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'.split('')}, | |
...givenOptions | |
}; | |
let code = ''; | |
while (code.length < length) { | |
code += pool[Math.floor(Math.random() * pool.length)]; | |
} | |
return code; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment