Skip to content

Instantly share code, notes, and snippets.

@pedro-surf
Created June 13, 2019 20:33
Show Gist options
  • Save pedro-surf/827dc605a2d1bc465e714077c3097650 to your computer and use it in GitHub Desktop.
Save pedro-surf/827dc605a2d1bc465e714077c3097650 to your computer and use it in GitHub Desktop.
func1 = (myObjArray) => {
myObjArray.sort((a,b) => { return a.ranking - b.ranking; });
};
func2 = (myObjArray) => {
let acc = 0;
let len = myObjArray.length;
for(let i=0; i<len; i++) {
acc = acc + myObjArray[i].ranking;
}
return acc / len;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment