Functional Programming - Use the filter Method to Extract Data from an Array

So I think I have this solved but my array doest follow the final example EXACTLY. The only difference is the punctuation around the items in the object.

const filteredList = watchList.map(item =>({
  title: item["Title"],
  rating: parseFloat(item["imdbRating"])
})).filter(list => list.rating >= 8)

The resulting object is the same as what the question is asking for, without some quotation marks.

Im getting :

[ { title: 'Inception', rating: 8.8 },
  { title: 'Interstellar', rating: 8.6 },
  { title: 'The Dark Knight', rating: 9 },
  { title: 'Batman Begins', rating: 8.3 } ]

Where fcc wants:

[{"title": "Inception", "rating": "8.8"},
 {"title": "Interstellar", "rating": "8.6"}, 
{"title": "The Dark Knight", "rating": "9.0"},
 {"title": "Batman Begins", "rating": "8.3"}]

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.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

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

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

Link to the challenge:

You don’t want to change the type stored in the rating property.

1 Like

Tests want you to provide strings actually, not floats.

The result you get is not just the same without quotes.

The data type is a number, whereas the solution uses strings: 5 !== "5"

It is also worth pointing out that the operator does type coercion.

console.log('10' >= 8) // true

console.log(true >= false);  // true
console.log(true >= 1);  // true
console.log(false >= 0);  // true
1 Like