Lodash _.sum Method Example

The _.sum() function calculates the sum of array values.

Learn Lodash JS at Lodash JS Tutorial with Examples.

Lodash _.sum Method Example

const vals = [-2, 0, 3, 7, -5, 1, 2];

const sum = _.sum(vals);
console.log(sum);
In the code example, we compute and print the sum of array values.
6

Reference


Comments