'use strict'; const config = require('config'); const style = require('./style'); function getLeaders(points) { return Object.entries(points).sort(([, scoreA], [, scoreB]) => scoreB - scoreA).map(([username, score], index) => { if (index === 0) { return `${style.bold(`${config.usernamePrefix}${username}`)} with ${style.bold(`${score}`)} points`; } return `${style.bold(style.cyan(`${config.usernamePrefix}${username}`))} with ${style.bold(`${score}`)} points`; }).join(', '); } module.exports = getLeaders;