Use the filter Method to Extract Data from an Array, tricky challenge?

Hello :slight_smile:

This is a challenge I can’t figure out. What is wrong with my code? The console returns an empty array…
The challenge asks you to use the map() and filter() methods to return the titles where the rating is equal or greater than 8.

// Add your code below this line

let filteredList = => ({'title': x['Title'],
    'rating': x['imdbRating']})).filter((x) => x >= 8);

// Add your code above this line


Gee, I just compared my code to others, and the only thing I was supposed to do was use
filter((x) => x['rating'] >= 8); in place of
filter((x) => x >= 8);

1 Like

If you wanted to use x, you would need to destructure rating out of each object like:

filter(({rating: x}) => x >= 8);