Skip to content

Instantly share code, notes, and snippets.

@lamchau
Created March 5, 2014 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lamchau/9378419 to your computer and use it in GitHub Desktop.
Save lamchau/9378419 to your computer and use it in GitHub Desktop.
function min(array) {
if (Array.isArray(array)) {
return Math.min.apply(null, array.filter(isFinite));
}
throw {
name: "Illegal argument",
message: "Argument must be an array"
}
}
function max(array) {
if (Array.isArray(array)) {
return Math.max.apply(null, array.filter(isFinite));
}
throw {
name: "Illegal argument",
message: "Argument must be an array"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment