Product of values of all possible non | Function to find product of all elements in all subsets ; Driver Code
function product ( a , n ) { var ans = 1 ; var val = Math . pow ( 2 , n - 1 ) ; for ( var i = 0 ; i < n ; i ++ ) { ans *= Math . pow ( a [ i ] , val ) ; } return ans ; } var n = 2 ; a = [ 3 , 7 ] document . write ( product ( a , n ) ) ;