Skip to content

Instantly share code, notes, and snippets.

@spencewood
Created December 27, 2013 10:36
Show Gist options
  • Save spencewood/8145213 to your computer and use it in GitHub Desktop.
Save spencewood/8145213 to your computer and use it in GitHub Desktop.
Underscore mixin for averaging array numbers.
_.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