Skip to content

Instantly share code, notes, and snippets.

@NekoTashi
Created June 2, 2016 21:05
Show Gist options
  • Save NekoTashi/b7cefa9922c7f3cdb5e2d177f5b1374a to your computer and use it in GitHub Desktop.
Save NekoTashi/b7cefa9922c7f3cdb5e2d177f5b1374a to your computer and use it in GitHub Desktop.
Ejemplo simple de .map() y .filter().
// 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