1-liners
Version:
Useful oneliners and shorthand functions
26 lines (23 loc) • 451 B
JavaScript
/**
* @module 1-liners/product
*
* @description
*
* Returns the product of all items of an `array`.
*
* @example
*
* const product = require('1-liners/product');
*
* product([2, 3, 4]); // => 24
* product([]); // => 1
*
*/
;
exports.__esModule = true;
exports["default"] = function (array) {
return array.reduce(function (a, b) {
return a * b;
}, 1);
};
module.exports = exports["default"];