fix bugs
This commit is contained in:
parent
545832726f
commit
1e40ec50d5
@ -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;
|
||||
|
@ -21,6 +21,10 @@ export class Stats {
|
||||
}
|
||||
}
|
||||
|
||||
resetScore() {
|
||||
this.#score = 0;
|
||||
}
|
||||
|
||||
get highScore() {
|
||||
return this.#highScore;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user