var ratingList = filterByNolan.map(function(element){
var rating = [];
rating.push(Number(element.imdbRating));
return rating;
});
In the code above your are returning an array for each time you loop with the map function. The results will be something like [[8.8], [8.6], [9], [8.3]]. Its looks like the default behaviour of performing an add on arrays is to concatenate the results into a string.
You need to fix your map so that it returns a number for each iteration not an array:
var ratingList = filterByNolan.map(function(element){
return Number(element.imdbRating);
});
Hint: Your could do all this in one reduce function. On each iteration of reduce you can check the item.director.
Also at the end you will need to divide the total by the array length.
Thank you randelldawon, your advice have help me through many challenges.
Just to note, when I went through this challenge, it is important to call reduce() with a initial value of 0. Otherwise, it assumes that the accumulator is an array.