Created
October 20, 2019 07:41
-
-
Save gbols/ff05850a222d7b4d675ff538ca94afdb 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
const users = [ | |
{ | |
name: "matt sanders", | |
rank: 5 | |
}, | |
{ | |
name: "winifred bony", | |
rank: 2 | |
}, | |
{ | |
name: "gbolahan olagunju", | |
rank: 1 | |
} | |
] | |
const sortedbyRank = users.sort((a, b) => b.rank < a.rank); | |
console.log(sortedbyRank) | |
const averageRanking = (users) => { | |
const total = users.reduce((total, current) => total + current.rank, 0); | |
return total / users.length; | |
} | |
console.log(averageRanking(users)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment