Created
June 2, 2016 21:05
-
-
Save NekoTashi/b7cefa9922c7f3cdb5e2d177f5b1374a to your computer and use it in GitHub Desktop.
Ejemplo simple de .map() y .filter().
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
// función map | |
var numeros = [1, 4, 9]; | |
var sumarUno = function(elemento) { | |
return elemento + 1; | |
}; | |
resultado = numeros.map(sumarUno); | |
console.log(resultado); | |
// [ 2, 5, 10 ] | |
// función filter | |
var numeros = [1, 4, 9]; | |
var excluirCuatro = function(elemento) { | |
return elemento !== 4; | |
}; | |
resultado = numeros.filter(excluirCuatro); | |
console.log(resultado); | |
// [ 1, 9 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment