Skip to content

Instantly share code, notes, and snippets.

@ojengwa
Created August 27, 2018 04:34
Show Gist options
  • Save ojengwa/9b9c02577f58a278bfcc74ec719234b9 to your computer and use it in GitHub Desktop.
Save ojengwa/9b9c02577f58a278bfcc74ec719234b9 to your computer and use it in GitHub Desktop.
ombudsman.js
// 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