Home Reference Source Test Repository

lib/product.js

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.product = product;
/**
 * Returns the product of the numbers of a list.
 *
 * @since v0.1.0
 * @param {Array} list - The array of numbers
 * @return {Number} The product of the numbers
 * @example
 *   product([1, 2, 3]) // => 6
 *   product([991, 10, 33]) // => 327030
 *
 *   product([5, -10, 3]) // => -150
 */
function product(list) {
  return list.reduce(function (prev, curr) {
    return prev * curr;
  }, 1);
}