-
-
Save wachunei/3a563088be714ef11d0b to your computer and use it in GitHub Desktop.
Repartidor web js
This file contains hidden or 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 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