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

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

#1

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 = watchList.map((x) => ({'title': x['Title'],
    'rating': x['imdbRating']})).filter((x) => x >= 8);

// Add your code above this line

console.log(filteredList); 


#2

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);


#3

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

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