Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sum.js 453B

123456789101112131415161718192021222324
  1. var baseSum = require('./_baseSum'),
  2. identity = require('./identity');
  3. /**
  4. * Computes the sum of the values in `array`.
  5. *
  6. * @static
  7. * @memberOf _
  8. * @since 3.4.0
  9. * @category Math
  10. * @param {Array} array The array to iterate over.
  11. * @returns {number} Returns the sum.
  12. * @example
  13. *
  14. * _.sum([4, 2, 8, 6]);
  15. * // => 20
  16. */
  17. function sum(array) {
  18. return (array && array.length)
  19. ? baseSum(array, identity)
  20. : 0;
  21. }
  22. module.exports = sum;