Created
February 25, 2020 19:28
-
-
Save munkacsitomi/659d16efe568ab944df9a084442c0577 to your computer and use it in GitHub Desktop.
How to use rest parameters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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