reordered function to fix warning

This commit is contained in:
Jack 2021-09-14 13:49:06 +01:00
parent d4b8f10504
commit ce93eb3a5f

View file

@ -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;
}