Array Methods! Pt. 1 (filter, map)
Starting off with the filter method, filter seems very self explanatory; we filter anything we’d like from the array.
The example above shows that I have an array of sneakers that holds four sneaker values. What is then done is that we create a const named filteredSneakers and have it set the filter method which creates an arrow function to return sneakers that’s price is equal to or lower than two hundred. I console.log the const and then shows what the results that the method has filtered out.
One of the most common methods I’ve used was map. The map method mutates an array and returns a new array of whatever value you want.
With the example above, we haven’t changed much at all. We only changed the method being used and then just used the argument and set it to a key of name which then prints out the results we see on line 14 and beyond when using console.log.
Thats all of the methods I will be discussing about for now! Short and sweet is how I assume most readers would like it. I will be writing more methods for arrays in future blogs so keep on the look out. Once again thank you so much for reading! Keep coding on!