Added playable round to letters game.
This commit is contained in:
16
src/utils/get-leaders.js
Normal file
16
src/utils/get-leaders.js
Normal 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;
|
||||
7
src/utils/get-word-key.js
Normal file
7
src/utils/get-word-key.js
Normal file
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
function getWordKey(word) {
|
||||
return word.split('').sort().join('');
|
||||
}
|
||||
|
||||
module.exports = getWordKey;
|
||||
Reference in New Issue
Block a user