Skip to content

Instantly share code, notes, and snippets.

@francistito
Created September 27, 2018 13:07
Show Gist options
  • Save francistito/be304b6b85a19ef62b4b76b2e31a100a to your computer and use it in GitHub Desktop.
Save francistito/be304b6b85a19ef62b4b76b2e31a100a to your computer and use it in GitHub Desktop.
let ranks = [{name:'one',rank:1},{name:'two',rank:2}];
let getByRanks = (ranks)=>{
return _.sortBy(_pluck(ranks,'rank'), function(num) {
return num;
})
};
let getRankAverage = (ranks)=>{
return _.reduce(_.pluck(ranks,'rank'), function(memo, num) {
return memo + num;
}, 0) / (arr.length === 0 ? 1 : arr.length);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment