Skip to content

Instantly share code, notes, and snippets.

@tecnocrata
Forked from JasonDeving/Max Number with es6
Created January 31, 2018 15:37
Show Gist options
  • Select an option

  • Save tecnocrata/e5f5fe86144e9a4ecf45567ce9396c98 to your computer and use it in GitHub Desktop.

Select an option

Save tecnocrata/e5f5fe86144e9a4ecf45567ce9396c98 to your computer and use it in GitHub Desktop.
FInd the max number with es6 with an array.
let numbers = [4,6,3,8];
let max = Math.max(...numbers);
console.log(max);
@tecnocrata
Copy link
Author

Best applied solution is:
[1,2,3,4].reduce((max, n) => n > max ? n : max)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment