Added playable round to letters game.

This commit is contained in:
2022-10-21 05:07:32 +02:00
parent 4534a1debe
commit 55343d5de7
7 changed files with 160 additions and 48 deletions

16
src/utils/get-leaders.js Normal file
View File

@@ -0,0 +1,16 @@
'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;

View File

@@ -0,0 +1,7 @@
'use strict';
function getWordKey(word) {
return word.split('').sort().join('');
}
module.exports = getWordKey;