Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 2
    +1 but use y: data.reduce((max, point) => Math.max(max, point.y), data[0].y); Many of the other answers create unnecessary temporary arrays or do expensive sorting. Using reduce() plus Math.max() is memory and CPU efficient, and it's more readable. Commented Sep 12, 2020 at 7:13
  • As mentioned above, can replace initial value with -Infinity. Commented Mar 5, 2024 at 17:31