Skip to content

Instantly share code, notes, and snippets.

@lucasdellasala
Created July 29, 2020 19:56
Show Gist options
  • Save lucasdellasala/8e14523c65a2f7a802b304e95f6c72d8 to your computer and use it in GitHub Desktop.
Save lucasdellasala/8e14523c65a2f7a802b304e95f6c72d8 to your computer and use it in GitHub Desktop.
Clase 2
var lista = ["Lucas", "Matías", "Nicolás", "Heidy", "Analía", "Pedro"];
exports.lista = lista;
var lista = require("./lista");
var repartidor = require("./repartidor");
repartidor.armarEquipos(lista.lista);
function armarEquipos (lista) {
if(lista.length !== 4 && lista.length !== 6){
console.log("Necesitas tener 4 o 6 jugadores para poder armar grupos");
return;
}
for (var i = lista.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp;
temp = lista[i];
lista[i] = lista[j];
lista[j] = temp;
}
var mensaje = "Equipo 1: " + lista[0] + ", " + lista[2] + ", " + lista[4] + ". Equipo 2: " + lista[1] + ", " + lista[3] + ", " + lista[5];
console.log(mensaje);
}
exports.armarEquipos = armarEquipos;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment