diff --git a/client/src/components/Code/index.tsx b/client/src/components/Code/index.tsx index 7134614..5e496dc 100644 --- a/client/src/components/Code/index.tsx +++ b/client/src/components/Code/index.tsx @@ -70,7 +70,7 @@ function Code({code, loaded}: CodeProps) { const incorrectlyTyped = characters.filter(char => !char).length; if (timer > 0) { - setScore((typed / 5 - incorrectlyTyped) / (timer / 60)); + setScore(Math.abs(typed / 5 - incorrectlyTyped) / (timer / 60)); setAccuracy(correctlyTyped / typed * 100); } // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/client/src/components/Stats/index.tsx b/client/src/components/Stats/index.tsx index 18097cc..50b6443 100644 --- a/client/src/components/Stats/index.tsx +++ b/client/src/components/Stats/index.tsx @@ -1,12 +1,13 @@ import { useTypingContext } from "contexts/typing"; import './index.css'; +import { renderTimer } from "./utils"; type StatsProps = { loaded: boolean; } -function Score({loaded}: StatsProps) { +function Score({ loaded }: StatsProps) { const { timer, score, @@ -17,7 +18,7 @@ function Score({loaded}: StatsProps) { return (
Time: {timer}
+ {renderTimer(timer)}WPM: {Math.round(score)}
Accuracy: {Math.round(accuracy)}%
Time: {leftValue < 10 && 0}{leftValue}:{rightValue < 10 && 0}{rightValue}
+ ); +}