Created
September 7, 2020 00:41
-
-
Save jerlyrosa/469e63e9f78951889b84b2f05e8c1c1a to your computer and use it in GitHub Desktop.
Funcion para comprender como trabaja el metodo filter() en javascript
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
// Problema para dar a entender o dar la idea de como funciona el metodo filter teniendiendo en cuenta | |
// que ya sabes algo de su parte teorica. | |
var arr = [1,2, 2, 4,];// Array original | |
const arrayFilter=(arr)=>{ | |
let result = arr.filter( (element, index, array) =>{ | |
console.log(element);// Primer elemento del Array | |
console.log(index);// indice de cada Array | |
console.log(array)// copia de Array original; | |
return element === 2// condicion | |
}); | |
return console.log(result)// result = [ 2, 2 ] | |
} | |
arrayFilter(arr); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment