Last active
August 29, 2015 14:22
-
-
Save SCJLabs/53dd7057f1eed85943b5 to your computer and use it in GitHub Desktop.
Generate a unique ID number. You can specify how many characters you want the length to be
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
//Generate a unique ID number | |
function generateUniqueID() { | |
var length = 10; | |
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
var result = ''; | |
for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))]; | |
return result; | |
} | |
//Usage: declare variable then assign it the value of the newly generated ID | |
var unique_id = generateUniqueID(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment