Full typescript and mvvm implementation #3

Merged
Schmidii99 merged 26 commits from Developer into main 2023-04-23 20:02:32 +02:00
2 changed files with 6 additions and 2 deletions
Showing only changes of commit 1e40ec50d5 - Show all commits

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