Files
lodash/sum.js
John-David Dalton 54e7baecc3 Bump to v4.0.0.
2016-01-12 00:17:29 -08:00

24 lines
445 B
JavaScript

import baseSum from './internal/baseSum';
import identity from './identity';
/**
* Computes the sum of the values in `array`.
*
* @static
* @memberOf _
* @category Math
* @param {Array} array The array to iterate over.
* @returns {number} Returns the sum.
* @example
*
* _.sum([4, 2, 8, 6]);
* // => 20
*/
function sum(array) {
return (array && array.length)
? baseSum(array, identity)
: undefined;
}
export default sum;