Use reduce() to analyze data

Tell us what’s happening:
My code provides the correct answer to what the problem asks but it doesn’t pass the test.

The entire code wouldn’t fit below so I only added what I wrote and not the object.

Any help is appreciated. Thanks.

Your code so far


function getRating(watchList){
// Only change code below this line
let chris = watchList.filter(
  list => list["Director"] == "Christopher Nolan"
);
let ratings = chris.map(
  rating => rating["imdbRating"]
);
let conv = ratings.map(parseFloat);


let averageRating = conv.reduce((avg, rate) => avg + rate / 4,0);


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

Your browser information:

User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 13_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0 EdgiOS/45.9.18 Mobile/15E148 Safari/605.1.15.

Challenge: Use the reduce Method to Analyze Data

Link to the challenge:

which tests are you failing?

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

It says I should be modifying ‘watchList’ but I thought the purpose of using map() filter() was to not modify the original array.

ah, no, that means that it should work with different watchList objects, not just the one in the editor - your function needs to be reusable

Ok I’ll take a look again tonight when I have time. Thank you.