Hi - Am trying to make sure I understand this and not just look for an answer…
Questions - To the parameters to filter() or ie reduce, map which are all somewhat similar. How do the parameter lists work?
Can you only use what is in the doc? element, index, array?
I assume you can use different / additional parameters? How does JS interpret which each parameter means? Do you need a specific order?
How with the ,0 (or other number) at the end do you initialize specific parameters?
Below - I think JS is thinking ‘‘totalRatings’’ is the index it’s on… So, the prints out are adding the rating in the element to the index value… which of course is not what I want. Where is the error please for it to treat that as an accumulative total I want to add to?
For finding the average - can i use nolan.length?.. or I think /x.length after the ,0 in other examples online.
They are not that similar. filter() expect a Boolean from the callback function, and returns an array containing only the elements for which the callback returned true (excluding those for which the callback function returned false).
In the first case you use filter correctly, but in the second one you are trying to make operations inside the filter method, it will not work.
You may want to read again on what those methods do, and use a different one for that.