Collect.js reduce() Method
The reduce() method is used to reduce the collection elements into a single value according to the given callback. It works by passing the result of each iteration to the next one resulting in a single value in the end.
Parameters: The collect() method takes one argument that is converted into the collection and then reduce() method is applied on it. The reduce() method holds the callback function as parameter.
Return Value: This method returns the reduced value of the collection.
Below example illustrate the reduce() method in collect.js: