Concentration of juice after mixing n glasses in equal proportion | Function to return the concentration of the resultant mixture ; Driver Code
function mixtureConcentration ( n , p ) { var res = 0 ; for ( var i = 0 ; i < n ; i ++ ) res += p [ i ] ; res /= n ; return res ; } var arr = [ 0 , 20 , 20 ] ; var n = arr . length ; document . write ( mixtureConcentration ( n , arr ) . toFixed ( 4 ) ) ;