function getRating(watchList) {
// Only change code below this line
const averageRating = watchList
// Use filter to find films directed by Christopher Nolan
.filter(film => film.Director === "Christopher Nolan")
// Use map to convert their ratings from strings to numbers
.map(film => Number(film.imdbRating))
// Use reduce to add together their ratings
.reduce((sumOfRatings, rating) => sumOfRatings + rating) /
// Divide by the number of Nolan films to get the average rating
watchList.filter(film => film.Director === "Christopher Nolan").length;
So I recently completed the problems prior to this one where I learned about .map and . filter. But when it came to this question where they asked me to apply what I learned I couldn’t remember how to use them properly. Is that bad?
Also now that I have looked at the solution the process makes a lot of sense. I only have a question about the last line of code, how is the last line of code dividing to get the average? Is “.length” doing that?