Skip to content

Instantly share code, notes, and snippets.

@jonsadka
Created February 29, 2016 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonsadka/6d38a39831ae3265e84d to your computer and use it in GitHub Desktop.
Save jonsadka/6d38a39831ae3265e84d to your computer and use it in GitHub Desktop.
Random team generator
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);
@RVaka18
Copy link

RVaka18 commented May 12, 2016

A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment