If all element are negative then return the maximum element
if ( areAllNegative ( arr ) ) { let mx = - 1000000000 ; for ( let i = 0 ; i < size ; i ++ ) { if ( arr [ i ] > mx ) mx = arr [ i ] ; } return mx ; }