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;
}
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/79.0.3945.79 Safari/537.36
.
Challenge: Use the reduce Method to Analyze Data
Link to the challenge: