Skip to content

Instantly share code, notes, and snippets.

@tharun208
Created March 19, 2018 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tharun208/8eaa05dc99c62e61ff4e60cca4ad7d21 to your computer and use it in GitHub Desktop.
Save tharun208/8eaa05dc99c62e61ff4e60cca4ad7d21 to your computer and use it in GitHub Desktop.
function to get Average and another to return object sorted on based on ranking
function getAverage(object)
{
for (const index of object) {
sum+=index.ranking;
}
return sum/object.length;
}
function sortBasedOnRanking(object)
{
for(var key in object){
if(obj.hasOwnProperty(key)){
keys.push(key);
}
}
keys.sort();
var len = keys.length();
for(i=0;i<len;i++){
sortkey=keys[i];
console.log(object[sortkey]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment