From 082e3483b2a643de700fdde094e5f1e856271adb Mon Sep 17 00:00:00 2001 From: Sandu Victor Date: Sat, 25 Apr 2020 14:06:04 +0300 Subject: [PATCH] fix: bug where the calculated typing speed was lower than the actual typing speed --- .../web/src/components/common/typingBox/typingBox.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/web/src/components/common/typingBox/typingBox.tsx b/packages/web/src/components/common/typingBox/typingBox.tsx index 0d03289..d9ca445 100644 --- a/packages/web/src/components/common/typingBox/typingBox.tsx +++ b/packages/web/src/components/common/typingBox/typingBox.tsx @@ -39,11 +39,11 @@ export const TypingBox = (props: typingBoxProps) => { ): number => { const charTyped = array .map((value: typedArrayInterface) => { - return value.state === "correct" ? value.word.length : 0; + return value.state === "correct" ? value.word.length + 1 : 0; }) - .reduce((prev: number, currentValue: number) => { - return prev + currentValue; - }); + .reduce((previous: number, current: number) => { + return previous + current; + }, 0); return Math.floor(charTyped / ((60 - time === 0 ? 1 : 60 - time) / 60)); };