Use the filter Method to Extract Data from an Array. I have rating & title in the wrong order, so the test can't be passed?


In the console log, I get the following with my code:

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

To pass the test, it should be title first & then rating, not rating then title. How can I correct this, please?

My code:

var filteredList = watchList
  .map(movie => ({
           title: movie.Title,
           rating: movie.imdbRating        

  .filter(movie => {
   movie.rating = +movie.rating;
    return movie.rating >= 8.0;

Required result:

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36

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

Link to the challenge:

This mutation might be a problem

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.