The average() method is used to return the average of all the items in a collection. This method is an alias of avg() method.
Parameters: The collect() method takes one argument that is converted into the collection and then average() function is applied on it, which can take element if you apply it on the collection of objects.
Return Value: This method returns a number which is average of the collection.
Below example illustrate the average() method in collect.js:
Average of the given array: 20
Average score of students: 91.33333333333333