Created
March 19, 2018 17:57
-
-
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
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
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