diff --git a/game.html b/game.html index fba5b75..61b69ba 100644 --- a/game.html +++ b/game.html @@ -63,6 +63,11 @@ +
+ High Score: + 0 +
+ diff --git a/game.js b/game.js index 491c141..7c5e68a 100644 --- a/game.js +++ b/game.js @@ -6,6 +6,7 @@ var nextCpu; // current user score var score; +var highScore; export async function main() { await (fetch('./data.json') @@ -15,6 +16,7 @@ export async function main() { currentCpu = getRandomCpu(); nextCpu = getRandomCpu(); score = 0; + highScore = 0; updateLayout(); } @@ -40,6 +42,10 @@ function showResult(isCorrect) { document.getElementById("col2").style.backgroundColor = isCorrect ? "lightgreen" : "#FF4444"; score = isCorrect ? score + 1 : 0; + if (score > highScore) { + highScore = score; + document.getElementById("highScore").innerText = highScore; + } document.getElementById("score").innerText = score; countUp();