Skip to content

Instantly share code, notes, and snippets.

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