Skip to content

Instantly share code, notes, and snippets.

@wachunei
Forked from lopezjurip/main.js
Last active September 4, 2015 14:05
Show Gist options
  • Save wachunei/3a563088be714ef11d0b to your computer and use it in GitHub Desktop.
Save wachunei/3a563088be714ef11d0b to your computer and use it in GitHub Desktop.
Repartidor web js
var turn = 0;
var teams = ['Rupie', 'TheTeam', 'Veritas', 'ImaginApp', 'Nebuchadnezzar', 'InternalServerError'];
var patoTeams = ['YisusPlusOne', 'ZipCity2000', 'tqzptscsaj'];
var pedroTeams = ['String.random','ToPa'];
var thomasTeams = ['LosExtraterrestresMusicales', 'Rock and Prog', 'PW:Software'];
var result = teams.sort(function(){return 0.5 - Math.random();})
.reduce(function(previous, current) {
previous[['pato', 'thomas', 'pedro'][turn++ % 3]].push(current);
return previous;
}, {
pato: patoTeams,
thomas: thomasTeams,
pedro: pedroTeams
});
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment