diff --git a/frontend/public/games/Fruit Slice/script.js b/frontend/public/games/Fruit Slice/script.js index d78c0ce6..4b8a6d3d 100644 --- a/frontend/public/games/Fruit Slice/script.js +++ b/frontend/public/games/Fruit Slice/script.js @@ -98,6 +98,6 @@ canvas.addEventListener("mousemove", (e) => { document.getElementById("restart-btn").addEventListener("click", resetGame); // Spawn fruits continuously -setInterval(spawnFruit, 900); +clearInterval(window.__interval); window.__interval = setInterval(spawnFruit, 900); update(); diff --git a/frontend/public/games/flappyBird/flappy.js b/frontend/public/games/flappyBird/flappy.js index e6dbae00..689b263f 100644 --- a/frontend/public/games/flappyBird/flappy.js +++ b/frontend/public/games/flappyBird/flappy.js @@ -52,7 +52,7 @@ bottomPipeImg= new Image(); bottomPipeImg.src="bottompipe.png"; requestAnimationFrame(update); -setInterval(placePipes, 1500); //1.5 sec +clearInterval(window.__interval); window.__interval = setInterval(placePipes, 1500); //1.5 sec document.addEventListener("keydown",moveBird); }; context.drawImage(birdImg, bird.x, bird.y, bird.width, bird.height); diff --git a/frontend/public/scripts/memory.js b/frontend/public/scripts/memory.js index bb4a7e10..9dc728e8 100644 --- a/frontend/public/scripts/memory.js +++ b/frontend/public/scripts/memory.js @@ -120,7 +120,7 @@ function gameWon() { gameActive = false; // Check for best score - if (!bestScore || moves < parseInt(bestScore)) { + if (!bestScore || moves < parseInt(bestScore, 10)) { bestScore = moves; localStorage.setItem('memoryBestScore', bestScore); document.getElementById('bestScore').textContent = bestScore; diff --git a/frontend/public/scripts/rps.js b/frontend/public/scripts/rps.js index 509b96a1..4a2e4559 100644 --- a/frontend/public/scripts/rps.js +++ b/frontend/public/scripts/rps.js @@ -5,7 +5,7 @@ const choices = { scissors: { emoji: "✂️", name: "Scissors" }, }; -let scores = JSON.parse(localStorage.getItem("rpsScores")) || { +let scores = (JSON.parse(localStorage.getItem("rpsScores") ?? "null") ?? null) || { player: 0, computer: 0, draws: 0,