Test failing on "Your code should use the reduce method"

Tell us what’s happening:
I keep failing the tests on use the reduce method to analyze data, despite using the reduce method. It even failed when I pasted in the solution code.

Your code so far

  // Only change code below this line
  var averageRating = 
  watchList
    .filter(movie => movie.Director == "Christopher Nolan")
    .map(movie => Number(movie.imdbRating))
    .reduce((sumRat, rating) => sumRat + rating) / 
  watchList.filter(movie => movie.Director === "Christopher Nolan").length;


  // Only change code above this line
  return averageRating;
}

Replace these two sentences with your copied code.
Please leave the line above and the line below,
because they allow your code to properly format in the post.

Your browser information:

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

Challenge: Use the reduce Method to Analyze Data

Link to the challenge:

Hi @wimsy !

Welcome to the forum!

This challenge has some weird bug in it.
When I place it all on one line it passes for me

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


  // Only change code above this line
  return averageRating;
}
console.log(getRating(watchList));
2 Likes

thats was the trick @jwilkins.oboe ! thank you!

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