mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-30 02:39:05 +08:00
reordered function to fix warning
This commit is contained in:
parent
d4b8f10504
commit
ce93eb3a5f
1 changed files with 12 additions and 12 deletions
|
|
@ -44,6 +44,18 @@ export function updateScore(char, isCorrect) {
|
|||
scores[char].update(score);
|
||||
}
|
||||
|
||||
function score(word) {
|
||||
let total = 0.0;
|
||||
let numChars = 0;
|
||||
for (const c of word) {
|
||||
if (c in scores) {
|
||||
total += scores[c].average;
|
||||
numChars++;
|
||||
}
|
||||
}
|
||||
return numChars == 0 ? 0.0 : total / numChars;
|
||||
}
|
||||
|
||||
export function getWord(wordset) {
|
||||
let highScore;
|
||||
let randomWord;
|
||||
|
|
@ -57,15 +69,3 @@ export function getWord(wordset) {
|
|||
}
|
||||
return randomWord;
|
||||
}
|
||||
|
||||
function score(word) {
|
||||
let total = 0.0;
|
||||
let numChars = 0;
|
||||
for (const c of word) {
|
||||
if (c in scores) {
|
||||
total += scores[c].average;
|
||||
numChars++;
|
||||
}
|
||||
}
|
||||
return numChars == 0 ? 0.0 : total / numChars;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue