Created
June 30, 2019 17:08
-
-
Save gagsy/a4d1cf994f3c02cecf4f707d36830dc3 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
import _ from 'underscore'; | |
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