DEV Community

Discussion on: 1 line of code: How to get highest numeric item of an Array

Collapse
 
jonrandy profile image
Jon Randy πŸŽ–οΈ • Edited

Probably need to be a bit careful describing what the function does. The function here will actually return the highest coerced numeric value from the array ('biggest' is also slightly ambiguous):

biggestItem([[], "1e6", false, "0xffffff"])   // 16777215
Enter fullscreen mode Exit fullscreen mode

It will also return -Infinity if an empty array is passed, and return NaN if any item in the array cannot be coerced to a Number.

Collapse
 
martinkr profile image
Martin Krause

Thank you for your comment.
I will update the article