When using .map() and .filter() methods together is there a preferred and/or recommended order to use them in?
While completing the ‘Use the filter Method to Extract Data from an Array’ problem in the ‘Functional Programming’ section of the JS curriculum you use both these methods together.
My solution (see below) passed, however, when looking at the solutions FCC provides I noticed that they all use .filter() before .map().
Is there a specific reason for this (i.e. preferred method, avoiding bugs in more complex code, better readability, etc.) or is it just how they chose to order them?
const filteredList = watchList
.map( movies => ({title: movies['Title'], rating: movies.imdbRating }))
.filter(score => parseFloat(score.rating) >= 8.0 );
FCC solution:
const filteredList = watchList
.filter(movie => movie.imdbRating >= 8.0)
.map(movie => ({ title: movie["Title"], rating: movie["imdbRating"] }));