max = Math.max(max, current);

https://ift.tt/30RZpaQ