var max = function max() {
// grab the first number to compare against
// this will be undefined if arguments is empty
var maxValue = arguments[0];
// loop through the remaining numbers
for (var i = 1; i < arguments.length; i++) {
// if the current element is greater
// than the maxValue
if (arguments[i] > maxValue) {
// replace maxValue with the current number
maxValue = arguments[i];
}
}
// return the result
return maxValue;
};
Created
October 5, 2015 19:15
-
-
Save gaand/64555f89cf76825447a5 to your computer and use it in GitHub Desktop.
Max
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment