before anyone accuses me of trying to be a smarta#$, note that i really didn’t do this on purpose, and it could have been avoided if I read the directions more carefully . I sat over this for a bit trying to figure out why the average wasn’t coming out to what the exercise required. So i messed around a bit. Only after the code passed realized it wanted the average of all the movies by a certain director, and I fixed it. however
this monstrosity did pass. even though it shouldn’t, because it doesnt do what the exercise requires… Just saying…
var averageRating;
var arr=[];
var rating = watchList.map(function(obj){ return arr.push(parseFloat(obj.imdbRating));
})
console.log(arr);
var averageRating= Math.floor((arr.reduce(function(a,b){
return a+b;
},)/arr.length+0.1555)*1000)/1000;
p.s. here is the link to the exercise:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/functional-programming/use-the-reduce-method-to-analyze-data
the ask for help link wasnt working…