[Solved] JavaScript Rank Leaderboard [closed]
Use an object and sort it using a sort function const results = { ‘UserA’: { points: 490 }, ‘UserB’: { points: 26 }, ‘UserC’: { points: 175 }, ‘UserD’: { points: 67 } } const rank = Object.entries(results) .sort(([, a], [, b]) => b.points – a.points) .map((item, i) => { results[item[0]].rank = (i + … Read more