Skip to content

Instantly share code, notes, and snippets.

@michaelwallett
Created January 29, 2014 17:04
Show Gist options
  • Save michaelwallett/8692302 to your computer and use it in GitHub Desktop.
Save michaelwallett/8692302 to your computer and use it in GitHub Desktop.
Team name generator
var sys = require("sys");
var fs = require('fs')
var adjectives = [];
var animals = [];
var stdin = process.openStdin();
stdin.addListener("data", function(d) {
if (adjectives.length === 0) {
adjectives = fs.readFileSync('adjectives.txt', 'utf8').split('\n').slice(0, -1);
}
if (animals.length === 0) {
animals = fs.readFileSync('animals.txt', 'utf8').split('\n').slice(0, -1);
}
var adjectiveIndex = Math.floor((Math.random() * adjectives.length));
var adjective = adjectives[adjectiveIndex];
var animalIndex = Math.floor((Math.random() * animals.length));
var animal = animals[animalIndex];
console.log(adjective.toLowerCase() + ' ' + animal.toLowerCase() + "s")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment