Array.prototype.reducebeginnerconst nums = [1, 2, 3, 4]
nums.reduce((acc, n) => acc * n, 1) // β 24Use reduce() with an initial accumulator of 1 to compute the product of all elements.
Use reduce() to multiply all elements together. The initial value for a product is 1 (the multiplicative identity).
[1, 2, 3, 4].reduce((acc, n) => acc * n, 1) // 24