Prefix Product Array | Function to generate prefix product array ; Update the array with the product of prefixes ; Print the array ; Driver Code
function prefixProduct ( a , n ) { for ( let i = 1 ; i < n ; i ++ ) { a [ i ] = a [ i ] * a [ i - 1 ] ; } for ( let j = 0 ; j < n ; j ++ ) { document . write ( a [ j ] + " " ) ; } return 0 ; } let arr = [ 2 , 4 , 6 , 5 , 10 ] ; let N = arr . length ; prefixProduct ( arr , N ) ;