Show Buttons
Share On Facebook
Share On Twitter
Share On Google Plus
Share On Linkdin
Share On Reddit
Contact us
Hide Buttons

Programming shorthands / tricks

 


Different ways to track the max value while iterating over different values

We can use if, ternary operator or Math.max function as shown below.

if (val > max) {
  max = val
}

max = val > max ? val : max

max = Math.max(max, val)


 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *