Created
October 9, 2018 00:46
-
-
Save linux08/c45cf459805bc8d8542389cf9ac6a6ec to your computer and use it in GitHub Desktop.
This file contains 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
//orders the item in an array of object by their ranking in ascending order | |
function sort(data) { | |
return data.sort((a, b) => { | |
return a.ranking - b.ranking; | |
}); | |
}; | |
//find the average ranking present in an array of object; | |
function average(data) { | |
return ( | |
data.reduce((prev, curr) => { | |
return prev + curr.ranking; | |
}, 0) / data.length | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment