This commit is contained in:
Florian Schmid 2023-04-19 20:48:51 +02:00
parent 545832726f
commit 1e40ec50d5
2 changed files with 6 additions and 2 deletions

View File

@ -8,7 +8,7 @@ var nextCpu;
var localStats;
export async function main() {
localStats = new Stats();
localStats = new Stats("highScore_cpu");
await (fetch('./js/data.json')
.then((response) => response.json())
@ -42,7 +42,7 @@ function showResult(isCorrect) {
document.getElementById("col2").style.backgroundColor = isCorrect ? "lightgreen" : "#FF4444";
void(isCorrect && (localStats.incrementScore()))
isCorrect ? localStats.incrementScore() : localStats.resetScore();
document.getElementById("highScore").innerText = localStats.highScore;
document.getElementById("score").innerText = localStats.score;

View File

@ -21,6 +21,10 @@ export class Stats {
}
}
resetScore() {
this.#score = 0;
}
get highScore() {
return this.#highScore;
}