Skip to content

Instantly share code, notes, and snippets.

@jbailey4
Created November 5, 2014 11:38
Show Gist options
  • Save jbailey4/a520b3df2d2ed8cce284 to your computer and use it in GitHub Desktop.
Save jbailey4/a520b3df2d2ed8cce284 to your computer and use it in GitHub Desktop.
Reduce an array to its largest or smallest value, using Array.prototype.reduce
// silly method, just learning the reduce method
function findBigOrSmall (a, l) {
return a.reduce(function (x, y) {
return l ? x > y ? x : y : x > y ? x : y;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment