Created
March 31, 2018 10:23
-
-
Save rluena/1d673b8f31e88a21a131de7575e5342c to your computer and use it in GitHub Desktop.
Interview question.
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
// Order by rank function | |
function orderByRank(arr) { | |
return arr.sort(function(a, b) { | |
return a.rank > b.rank; | |
}); | |
} | |
//Average ranking function | |
function avgRanking(arr) { | |
var total = arr.reduce(function(total, next) { | |
total = total + next.rank; | |
return total; | |
}, 0); | |
return total / arr.length; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment