The _.reduceRight() method is similar to _.reduce() method except that it iterates over elements of collection from right to left.
_.reduceRight(collection, iteratee, accumulator)
Parameters: This method accepts three parameters as mentioned above and described below:
- collection: This parameter holds the collection to iterate over.
- iteratee: This parameter holds the function invoked per iteration.
- accumulator: This parameter holds the initial value.
Return Value: This method returns the accumulated value.
Example 1: Here, const _ = require(‘lodash’) is used to import the lodash library in the file.
[ 14, 15, 12, 13, 10, 11 ]
[ 'Lodash', 'Python', 'DAA', 'Java', 'C++', 'C#' ]