Hoodfc
1/9/2020 - 10:02 AM

Recursive Product of Array

Calculate the product of every number on the given array, with recursion

// calculates the product of every number on the array, with recursion [#12]
function productOfArray(arr) {
    if(arr.length === 0) return 1;
    return arr[0] * productOfArray(arr.slice(1));
}