Javascript Reduce() Function

The reduce() function of array object apply a function simultaneously against two values of the array (from left-to-right) as to reduce it to a single value. Use it for example to perform operation on each element of an array.

Syntax

Javascript Reduce() Function Example1

This will produce following result

Javascript Reduce() Function Example2

This will produce following result