Functional Programming - Use the reduce Method to Analyze Data

Hi Guys,

I’m doing the Functional Programming but can someone please explain the reduce() part in the below code?
How does the “sumOfRating” and “rating” work?
Why do they use “sumOfRating” and “rating”?

function getRating(watchList) {
  // Only change code below this line
  let averageRating = watchList

  .filter(film => film.Director === "Christopher Nolan")
  .map(film => Number(film.imdbRating))
  .reduce((sumOfRating,rating) => sumOfRating + rating) /
  watchList.filter(film => film.Director === "Christopher Nolan").length
  // Only change code above this line
  return averageRating;

I think I answered this on Discord.
Are you the same person?

Yes I am . Thank you

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