Created
August 8, 2013 03:06
-
-
Save agustinhaller/6181104 to your computer and use it in GitHub Desktop.
makeId function
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
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; | |
} |
ES6 Eslint friendly version
const makeid = length => {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < length; i += 1) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
};
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ES6 Version