Created
December 27, 2013 10:36
-
-
Save spencewood/8145213 to your computer and use it in GitHub Desktop.
Underscore mixin for averaging array numbers.
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
_.mixin({ | |
average: function (arr) { | |
return _.reduce(arr, function (memo, num) { | |
return memo + num; | |
}, 0) / arr.length; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment