Created
August 24, 2011 14:34
-
-
Save javierbrea/1168201 to your computer and use it in GitHub Desktop.
Solucion al ejercicio Saludador multiple #gejs
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
//Saludador múltiple: Modificar la función anterior, ahora puede recibir un array de nombres y devuelve un array de funciones. Cada una de estas funciones saludará a la persona correspondiente según el orden del array. | |
var crearSaludo=function(names){ | |
var saludadores=[],z=names.length | |
var saludador=function(name){ | |
return function(){ | |
console.log('Hola '+name); | |
} | |
} | |
for(var i=0;i<z;i++){ | |
saludadores[i]= saludador(names[i]); | |
} | |
return saludadores; | |
} | |
var saludos=crearSaludo(["Pepe", "María"]); saludos[1]();saludos[0](); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment