Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
/**
2
* A specialized version of `_.sum` for arrays without support for iteratees.
3
*
4
* @private
5
* @param {Array} array The array to iterate over.
6
* @returns {number} Returns the sum.
7
*/
8
function arraySum(array) {
9
var length = array.length,
10
result = 0;
11
12
while (length--) {
13
result += +array[length] || 0;
14
}
15
return result;
16
}
17
18
module.exports = arraySum;
19
20