Returns maximum value in array, handling undefined values