Skip to content

Instantly share code, notes, and snippets.

@munkacsitomi
Created February 25, 2020 19:28
Show Gist options
  • Save munkacsitomi/659d16efe568ab944df9a084442c0577 to your computer and use it in GitHub Desktop.
Save munkacsitomi/659d16efe568ab944df9a084442c0577 to your computer and use it in GitHub Desktop.
How to use rest parameters
const multiMax = (first, ...remainingNumbers) => {
const max = remainingNumbers.sort((a, b) => b - a).find(a => a);
return first * max;
}
console.log(multiMax(3, 1, 2, 5, 4)); // 3 * 5 = 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment