Created
January 29, 2014 17:04
-
-
Save michaelwallett/8692302 to your computer and use it in GitHub Desktop.
Team name generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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