Program for harmonic mean of numbers | Function that returns harmonic mean . ; Driver code
function harmonicMean ( arr , freq , n ) { let sum = 0 , frequency_sum = 0 ; for ( let i = 0 ; i < n ; i ++ ) { sum = sum + ( freq [ i ] / arr [ i ] ) ; frequency_sum = frequency_sum + freq [ i ] ; } return frequency_sum / sum ; } let num = [ 13 , 14 , 15 , 16 , 17 ] ; let freq = [ 2 , 5 , 13 , 7 , 3 ] ; let n = num . length ; document . write ( harmonicMean ( num , freq , n ) ) ;