mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-11 08:14:11 +08:00
fixed live wpm and raw calculation (avoiding newlines)
This commit is contained in:
parent
c601bb39ad
commit
72f6112807
1 changed files with 8 additions and 2 deletions
|
@ -3147,11 +3147,17 @@ function liveWpmAndRaw() {
|
|||
let chars = 0;
|
||||
let correctWordChars = 0;
|
||||
let spaces = 0;
|
||||
let newlineoffset = 0;
|
||||
for (let i = 0; i < inputHistory.length; i++) {
|
||||
if (inputHistory[i] == wordsList[i]) {
|
||||
let word = wordsList[i + newlineoffset];
|
||||
if (word === "\n") {
|
||||
newlineoffset++;
|
||||
word = wordsList[i + newlineoffset];
|
||||
}
|
||||
if (inputHistory[i] == word) {
|
||||
//the word is correct
|
||||
//+1 for space
|
||||
correctWordChars += wordsList[i].length;
|
||||
correctWordChars += word.length;
|
||||
if (i < inputHistory.length) {
|
||||
spaces++;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue