Skip to content

Instantly share code, notes, and snippets.

@diegoglz-dev
Created February 25, 2023 00:29
Show Gist options
  • Select an option

  • Save diegoglz-dev/e0794a95bd1e94716dfacb1e7d0ab611 to your computer and use it in GitHub Desktop.

Select an option

Save diegoglz-dev/e0794a95bd1e94716dfacb1e7d0ab611 to your computer and use it in GitHub Desktop.
Sorteo de equipos para fútbol 5
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