Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function maxBy(array, func)
- {
- var results = [];
- for (var key : var element in array)
- {
- results[key] = func(element);
- }
- return array[search(results, arrayMax(results))];
- }
- function maxBy2(array, func)
- {
- var maximum = null, foo = "On sent déjà l'utilité de cette variable...";
- for (var element in array)
- {
- (maximum==null)
- ?
- maximum = element
- :
- func(maximum) < func(element)
- ?
- maximum = element
- :
- foo = "Et c'est là qu'on est pas déçus x)";
- }
- return maximum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement