Created
August 27, 2018 04:34
-
-
Save ojengwa/9b9c02577f58a278bfcc74ec719234b9 to your computer and use it in GitHub Desktop.
ombudsman.js
This file contains hidden or 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
// const test_array = [{name: "Bernard", ranking: 100}, {name:"Messi", ranking: 1}, {name:"McCain", ranking: 17} ] | |
function sorted(list){ | |
return list.sort(function(a, b){ | |
return a.ranking - b.ranking; | |
}); | |
} | |
function average_ranking(list){ | |
var sum = list.reduce( function(prev_obj, this_obj) { return prev_obj + this_obj.ranking }, 0); | |
return sum / list.length; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment