Skip to content

Instantly share code, notes, and snippets.

@snsxn
Created August 26, 2022 14:38
Show Gist options
  • Save snsxn/402b120457ae72647d55d9ba4d23f952 to your computer and use it in GitHub Desktop.
Save snsxn/402b120457ae72647d55d9ba4d23f952 to your computer and use it in GitHub Desktop.
One-line get largest element of an Array - JavaScript ES2015, ES6
const getLargestElement = (arr) => arr.reduce((largest, num) => Math.max(largest, num));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment