Skip to content
Browse files

ripped out of fritter

  • Loading branch information...
0 parents commit 5f40cd5f21326075a39256161aa0a27b96eff57f @substack committed May 11, 2012
Showing with 17 additions and 0 deletions.
  1. +17 −0 index.js
17 index.js
@@ -0,0 +1,17 @@
+module.exports = function (n) {
+ function chr (s) { return s.charCodeAt(0) }
+ function pick (xs) {
+ var x = xs[Math.floor(Math.random() * xs.length)];
+ return String.fromCharCode(x);
+ }
+
+ var letters = [ chr('_') ];
+ for (var i = 0; i < 26; i++) letters.push(chr('A') + i);
+ for (var i = 0; i < 26; i++) letters.push(chr('a') + i);
+ var words = letters.slice();
+ for (var i = 0; i < 10; i++) words.push(chr('0') + i);
+
+ var output = pick(letters);
+ for (var i = 1; i < n; i++) output += pick(words);
+ return output;
+};

0 comments on commit 5f40cd5

Please sign in to comment.
Something went wrong with that request. Please try again.