Use the reduce Method to Analyze Data. Need Help!

Tell us what’s happening:

i’m getting 8.675 which is the correct average of the movies made by christopher Nolan but somehow my code is not returning the correct answer and i’m really confused as to what is the correct answer

Your code so far

function getRating(watchList){
  // Only change code below this line
  var averageRating = watchList.filter(movie => movie.Director === "Christopher Nolan")
                               .map(movie => parseFloat(movie.imdbRating))
                               .reduce((sum, rating) => sum + rating / 4, 0);

  // Only change code above this line
  return averageRating;

Your browser information:

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

Challenge: Use the reduce Method to Analyze Data

Link to the challenge:

the test that you are not passing

Your code should return correct output after modifying the watchList object.

is about making sure that the function is reusable with any object.
you don’t know that there are always 4 movies directed by Nolan

I suggest you look at documentation of reduce, there is a way to have the array as callback parameter, so you don’t need to hardcode a number:

i solved it.

i figured out a way to make my code get the sum of the movies directed by chris. Nolan and use it to find the average rating, that way i don’t have to hardcore a number.