Product of all Subarrays of an Array | Set 2 | Function to find the product of elements of all subarray ; Initialize the result ; Computing the product of subarray using formula ; Return the product of all elements of each subarray ; Given array arr [ ] ; Function Call
function SubArrayProdct ( arr , n ) { let result = 1 ; for ( let i = 0 ; i < n ; i ++ ) result *= Math . pow ( arr [ i ] , ( i + 1 ) * ( n - i ) ) ; return result ; } let arr = [ 2 , 4 ] ; let N = arr . length ; document . write ( SubArrayProdct ( arr , N ) ) ;