Functional Programming Help

Hey y’all first happy thanksgiving!

I’m working on Functional programming exercises specifically this one: https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/use-the-reduce-method-to-analyze-data

and below is my answer:

var averageRating = watchList.map(movie => Number(movie.imdbRating))
.reduce((accum, value) => accum += value, 0) / watchList.length;

Even when I average these by hand I get the same result as my JS (8.52) but I don’t understand for the life of me why the test output is:

// running tests
The averageRating should equal 8.675.
// tests completed

Is this a bug or am I missing something?

Thanks in advance!!!

Hi.

find the average IMDB rating of the movies directed by Christopher Nolan

Where is the Christopher Nolan filter in your code?

1 Like

Oh crap this is reaaaaaally embarrassing, I was averaging out the entire thing, if I could ‘read’ the instructions better would help, HAHA sorry got a lil excited with this one. Tnx for the help and sorry for the oversight.

1 Like