Tell us what’s happening:
I have one last task " Your code should return the correct output after modifying the watchList
object."
Your code so far
// Only change code below this line
var averageRating = watchList.filter(wl => wl["Director"] == "Christopher Nolan");
averageRating = averageRating.reduce((obj, ar) => {
obj[ar["Title"]] = ar["imdbRating"];
return obj;
}, {});
averageRating.Inception = parseFloat(averageRating.Inception);
averageRating.Interstellar = parseFloat(averageRating.Interstellar);
averageRating.['The Dark Knight'] = parseFloat(averageRating.['The Dark Knight']);
averageRating.['Batman Begins'] = parseFloat(averageRating.['Batman Begins']);
var sum = averageRating.Inception + averageRating.Interstellar + averageRating.['The Dark Knight'] + averageRating.['Batman Begins']
averageRating = sum / 4;
// Only change code above this line
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.3 Safari/605.1.15
.
Challenge: Use the reduce Method to Analyze Data
Link to the challenge: