Calling multiMax() at the bottom of the code block we pass in 4 arguments. I see how the rest of the logic plays out I just don’t get why alert(multi) is equal to ‘3’;
http://jsfiddle.net/captainill/AjEPV/
function multiMax(multi){
alert(multi);
// Make an array of all but the first argument
var allButFirst = Array().slice.call( arguments, 1 );
// Find the largest number in that array of arguments
var largestAllButFirst = Math.max.apply( Math, allButFirst );
// Return the multiplied result
return multi * largestAllButFirst;
}
alert( multiMax(3, 1, 2, 3) == 9, "3*3=9 (First arg, by largest.)" );
I’ve been going through these excellent little tutorials:
http://ejohn.org/apps/learn/#47
alert(multi)displays “3” becausemultiis the first argument, and 3 is the first value you’re passing to the function.