Created
July 29, 2020 19:56
-
-
Save lucasdellasala/8e14523c65a2f7a802b304e95f6c72d8 to your computer and use it in GitHub Desktop.
Clase 2
This file contains 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 lista = ["Lucas", "Matías", "Nicolás", "Heidy", "Analía", "Pedro"]; | |
exports.lista = lista; |
This file contains 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 lista = require("./lista"); | |
var repartidor = require("./repartidor"); | |
repartidor.armarEquipos(lista.lista); |
This file contains 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 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