How is average calculated in reduce() exercise

Tell us what’s happening:
The average rating that I’m getting by adding all the ratings and dividing by the number of ratings is 8.52. The exercise says that the average should be 8.675. How should the average be calculated?

Thanks beforehand

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;

 
 averageRating = watchList.reduce(function(sum, rates) {
  const aveR = sum + rates.imdbRating *1;
  return aveR}, 0);


  console.log("length of watchList", watchList.length);
  console.log("averageRating",averageRating);

  // Only change code above this line
  return averageRating/watchList.length;
}

console.log(getRating(watchList));

Your browser information:

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

Challenge: Use the reduce Method to Analyze Data

Link to the challenge:

Take a closer look at the instructions, there’s one detail specifying that not all ratings should be used.

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