Created
August 31, 2018 14:21
-
-
Save tosipaulo/1be92b04896886a61b8ea17e6726c463 to your computer and use it in GitHub Desktop.
group times
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
const times = [{id:'time a'},{id:'time b'},{id:' time c'},{id:'time d'},{id:'time e'}]; | |
const groups = (arr) => { | |
const output = []; | |
for(i = 0; i < arr.length; i++){ | |
for(j = 1; j < arr.length; j++){ | |
if(arr[i].id == arr[j].id){ | |
continue; | |
} | |
output.push([arr[i], arr[j]]) | |
} | |
} | |
return output | |
} | |
Excelente solução, porém para atender minha necessidade tiver que inverter os pares com se fosse jogos da segunda fase.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Essa essa logica, mas agora você falando percebi que na interação o valor time b x time a , time c x time a não estão aparecendo! Podemos melhorar ainda mais isso!