Skip to content

Instantly share code, notes, and snippets.

@allex
Created July 29, 2014 04:03
Show Gist options
  • Save allex/cc0cbd969b83c6d80343 to your computer and use it in GitHub Desktop.
Save allex/cc0cbd969b83c6d80343 to your computer and use it in GitHub Desktop.
// GistID:
// GistURL:
function getID(idLength) {
var chars = '0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,$,_'.split(',');
var min = 0, max = chars.length - 1, unique_id = '';
for (var i = 0; i < idLength; i++) {
unique_id += chars[Math.floor(Math.random() * (max - min + 1) + min)];
}
return unique_id;
}
var n = 5;
while (n--) console.log(getID(14) + '\n');
@farhet44
Copy link

farhet44 commented Aug 3, 2016

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment