Functional Programming - Use the reduce Method to Analyze Data

**Tell us what’s happening:**I need some help. My code is returning the average imdb rating of 10.65

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.

function getRating(watchList) {
  // Only change code below this line
  let averageRating = watchList
  .filter(movie => movie.imdbRating >= 8.0)
  .map(movie =>({title: movie["Title"], rating: movie["imdbRating"], director: movie["Director"]}));

  // Only change code above this line
  return averageRating = watchList.reduce((sum, movie) => sum + movie.imdbRating / averageRating.length, 0);
}

console.log(getRating(watchList));

Your browser information:

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

Challenge: Functional Programming - Use the reduce Method to Analyze Data

Link to the challenge:

Use reduce to find the average IMDB rating of the movies directed by Christopher Nolan .

I don’t think your filter does what its supposed to.

that was a loop hole i figured out all movie’s are directed but avatar and avatar has a imdbRating of 7.9 So i figured i can get isolate that out

But that’s not the same thing as finding all Nolan films. That won’t work for all tests.

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