Skip to content

Instantly share code, notes, and snippets.

@kodamirmo
Created May 22, 2016 04:57
Show Gist options
  • Save kodamirmo/a1d9c5ba7604eb023c56d37b24a3c37d to your computer and use it in GitHub Desktop.
Save kodamirmo/a1d9c5ba7604eb023c56d37b24a3c37d to your computer and use it in GitHub Desktop.
Codigo JS de Smash Faces
var arregloNombres =
['Irving', 'Emmanuel' ,'Gonzalez'];
// 0 1 2
function enteroRandomEnRango(min, max) {
var numero = Math.random() * (max - min) + min;
var entero = Math.floor(numero);
return entero;
};
while (arregloNombres.length > 0) {
//Ver el tamaño del arreglo
var tamano = arregloNombres.length;
//Generamos el numero al azar
var indice = enteroRandomEnRango(0, tamano);
console.log(arregloNombres[indice]);
console.log(arregloNombres[indice] + '.jpg');
arregloNombres.splice( indice ,1);
console.log(arregloNombres);
//splice(cortarDesde, cuantosElementos);
//Aqui ya tengo un nuevo areglo
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment