Product of numeric values

JavaScript, Math · Oct 22, 2020

Calculates the product of two or more numbers/arrays.

const prod = (...arr) => [...arr].reduce((acc, val) => acc * val, 1);
prod(1, 2, 3, 4); // 24
prod(...[1, 2, 3, 4]); // 24

More like this

  • Percentile of matches

    Calculates the percentage of numbers in the given array that are less or equal to the given value.

    JavaScript, Math · Oct 22, 2020

  • Cartesian product

    Calculates the cartesian product of two arrays.

    JavaScript, Math · Dec 29, 2020

  • Greatest common divisor

    Calculates the greatest common divisor between two or more numbers/arrays.

    JavaScript, Math · Dec 29, 2020