Skip to content

Instantly share code, notes, and snippets.

@etoxin
Created January 20, 2016 07:01
Show Gist options
  • Save etoxin/cbc4bbf60c27ddfd750b to your computer and use it in GitHub Desktop.
Save etoxin/cbc4bbf60c27ddfd750b to your computer and use it in GitHub Desktop.
Create a string that s random
/**
* @param lng {Number}
* @returns {string}
* @constructor
*/
function MakeId(lng) {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
for (var i = 0; i < lng; i++)
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