Created
May 21, 2016 23:25
-
-
Save daronwolff/2f60f60e519dbd82f18389a5178174a3 to your computer and use it in GitHub Desktop.
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
| function multiMax(multi){ | |
| // Make an array of all but the first argument | |
| var allButFirst = Array().slice.call(arguments); | |
| // Find the largest number in that array of arguments | |
| var largestAllButFirst = Math.max.apply(Math,allButFirst); | |
| // Return the multiplied result | |
| return multi * largestAllButFirst; | |
| } | |
| assert( multiMax(3, 1, 2, 3) == 9, "3*3=9 (First arg, by largest.)" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment