Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save daronwolff/2f60f60e519dbd82f18389a5178174a3 to your computer and use it in GitHub Desktop.

Select an option

Save daronwolff/2f60f60e519dbd82f18389a5178174a3 to your computer and use it in GitHub Desktop.
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