Last active
August 31, 2016 12:56
-
-
Save marcelweder/8ad71429a2b9429c5a5d to your computer and use it in GitHub Desktop.
Simple JS-Snippet to create random ID
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
function makeid(length) | |
{ | |
var text = ""; | |
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; | |
for(var i=0; i < length; i++) | |
{ | |
text += possible.charAt(Math.floor(Math.random() * possible.length)); | |
} | |
return text; | |
} | |
function make_puphpet(prefix) | |
{ | |
return prefix + '_' + makeid(12); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment