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: