Created
November 5, 2014 11:38
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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