Last active
July 21, 2020 20:54
-
-
Save negarjf/65cc7263f6d485a06e8d286d2d51abcd to your computer and use it in GitHub Desktop.
Generating unique random strings with optional prefix and postfix.
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
/** | |
* Generates random string id | |
* | |
* @param prefix | |
* @param postfix | |
* @returns {string} | |
*/ | |
function generateId(prefix, postfix) { | |
prefix = prefix || ""; | |
postfix = postfix || ""; | |
let hashId = Date.now().toString(36); | |
return prefix + hashId + postfix; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
😉