Filter&Map Functions

Tell us what’s happening:
I am having a hard time figuring out why my code returns an empty array. Can someone help me with that please?

Your code so far

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

const filteredList = watchList
.map(list=>({
  title: list.Title,
  rating: list.imdbRating
}))
.filter(list => parseFloat(list.imdbRating) >= 8.0)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36

Challenge: Use the filter Method to Extract Data from an Array

Link to the challenge:

in your fitler callback, you try to access list.imdbRating, but your object has only a property called rating

1 Like

Hello!

That’s because you’re mapping the list and extracting only the title and rating, converting each item in the list to this before you filter it:

{
    title: '...',
    rating: 'N.N',
}

Hence the property doesn’t exist and is always false.

1 Like