Created
February 25, 2023 00:29
-
-
Save diegoglz-dev/e0794a95bd1e94716dfacb1e7d0ab611 to your computer and use it in GitHub Desktop.
Sorteo de equipos para fútbol 5
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
| function shuffleArray(arregloJugadores){ | |
| arregloJugadores.sort(()=> Math.random() - 0.5); | |
| } | |
| var jugadores = [ | |
| "Nani", | |
| "Diego", | |
| "Braian", | |
| "Fede", | |
| "Manu", | |
| "Fran", | |
| "Joan", | |
| "Gastelo", | |
| "Julito", | |
| "Amigo Fran" | |
| ]; | |
| shuffleArray(jugadores); | |
| console.log(jugadores); | |
| let equipo1 = []; | |
| let equipo2 = []; | |
| for (i = 0; i < jugadores.length; i++) { | |
| if (i % 2 == 0) { | |
| equipo1.push(jugadores[i]); | |
| } else { | |
| equipo2.push(jugadores[i]); | |
| } | |
| } | |
| console.log(equipo1); | |
| console.log(equipo2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment