Created
February 29, 2016 17:39
-
-
Save jonsadka/6d38a39831ae3265e84d to your computer and use it in GitHub Desktop.
Random team 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
function doWork(){ | |
var referee = 'Jon'; | |
var peeps = ['Zach', 'Rachael', 'Reyna', 'Gloria', 'Zeus', 'Leighton', 'Tim', 'Will', 'Emily', 'Eric', 'Bruce', 'Real']; | |
var teamNames = [ | |
'Fire Breathing Rubber Duckies', 'Fire Breathing Rubber Duckies', 'Fire Breathing Rubber Duckies', | |
'The Cereal Killers', 'The Cereal Killers', 'The Cereal Killers', | |
'French Toast Mafia', 'French Toast Mafia', 'French Toast Mafia', | |
'Blue Barracudas', 'Blue Barracudas', 'Blue Barracudas' | |
] | |
var teams = {}; | |
peopleCount = peeps.length; | |
for (var i = 0; i < peopleCount; i++){ | |
var randomPeepIndex = Math.floor(Math.random()*(peeps.length - 1)); | |
peep = peeps.splice(randomPeepIndex, 1)[0]; | |
var randomTeamIndex = Math.floor(Math.random()*(peeps.length - 1)); | |
team = teamNames.splice(randomTeamIndex, 1)[0]; | |
teams[team] = teams[team] || [] | |
teams[team].push(peep); | |
} | |
return teams; | |
} | |
doWork(); | |
// JSON.stringify(teams, null, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A