** Your code should return the correct output after modifying the watchList object:**
Your code so far
function getRating(watchList){
// Only change code below this line
var 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;
// Add your 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/91.0.4472.106 Safari/537.36
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
To fix this, you just need to replace the ; with a different symbol to save the result on the next line into the averageRating variable.
As to how I debugged this - the failing test said the output was wrong. You are returning the averageRating variable, so I looked at your code to see what was being stored in that variable.
You won’t get help much faster than you get here on the forum unless you pay the hourly rate of a professional developer… which is not going to be cheep.
Personally, I just stick to giving away my knowledege for free on the forum.