Created
July 24, 2013 18:15
-
-
Save Sigmus/6073041 to your computer and use it in GitHub Desktop.
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
function best(fun, coll) { | |
return _.reduce(coll, function(x, y) { | |
return fun(x, y) ? x : y | |
}); | |
} | |
best(function(x,y) { | |
return x > y | |
}, [1,2,3,4,5]); | |
// 5 | |
best(function(x, y) { | |
return x.age > y.age | |
}, [{name: 'Flavio', age: 37},{name:'Lenita', age:35}]); | |
// {name: 'Flavio', age: 37} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment