Skip to content

Instantly share code, notes, and snippets.

@Takazudo
Created July 15, 2011 08:29
Show Gist options
  • Save Takazudo/1084321 to your computer and use it in GitHub Desktop.
Save Takazudo/1084321 to your computer and use it in GitHub Desktop.
randomChar.js
function randomNum(from, to) {
return from + Math.floor( Math.random() * (to - from + 1) );
}
function randomChar(length){
var library = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'];
var res = '';
for(var i=0; i<length; i++){
res = [res, library[randomNum(0,9)]].join('');
}
return res;
}
// randomChar(140)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment