Function: product()
product(
iterable:IterableResolvable<number>):number
Defined in: projects/utilities/packages/iterator-utilities/src/lib/product.ts:24
Consumes the iterable and returns the product of all the elements. If the iterable is empty, it returns 1.
Parameters
| Parameter | Type | Description |
|---|---|---|
iterable | IterableResolvable<number> | An iterator to calculate the product of. |
Returns
number
The product of the elements in the input iterator.
Example
import { product } from '@sapphire/iterator-utilities';
const iterable = [1, 2, 3, 4, 5];
console.log(product(iterable));
// Output: 120
const iterable = [1, 2, 3, 4, 5, 0];
console.log(product(iterable));
// Output: 0