From f3f2b5cc8494da31e7393c6a73deb696d7752713 Mon Sep 17 00:00:00 2001 From: Saurabh Kumar Bajpai Date: Tue, 4 Aug 2026 12:35:08 +0530 Subject: [PATCH] fix: resolve 4 bugs in GameHub --- frontend/public/games/Sliding Puzzle/script.js | 2 +- frontend/public/games/jump-counter/script.js | 2 +- frontend/public/scripts/tic-tac-toe.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/public/games/Sliding Puzzle/script.js b/frontend/public/games/Sliding Puzzle/script.js index 26baff6c..18a51111 100644 --- a/frontend/public/games/Sliding Puzzle/script.js +++ b/frontend/public/games/Sliding Puzzle/script.js @@ -20,7 +20,7 @@ function render() { if (num === "") { tile.classList.add("empty"); } else { - tile.innerText = num; + tile.textContent = num; tile.addEventListener("click", () => moveTile(i)); } diff --git a/frontend/public/games/jump-counter/script.js b/frontend/public/games/jump-counter/script.js index 2e8c225b..69c0662d 100644 --- a/frontend/public/games/jump-counter/script.js +++ b/frontend/public/games/jump-counter/script.js @@ -90,7 +90,7 @@ function createObstacle() { const moveObstacle = setInterval(() => { if (gamePaused) return; - let obstacleLeft = parseInt(obstacle.style.left); + let obstacleLeft = parseInt(obstacle.style.left, 10); if (obstacleLeft <= -40) { obstacle.remove(); obstacles.shift(); diff --git a/frontend/public/scripts/tic-tac-toe.js b/frontend/public/scripts/tic-tac-toe.js index be2c8d51..c17e0570 100644 --- a/frontend/public/scripts/tic-tac-toe.js +++ b/frontend/public/scripts/tic-tac-toe.js @@ -17,7 +17,7 @@ function saveScore(score) { let board = ['', '', '', '', '', '', '', '', '']; let currentPlayer = 'X'; let gameActive = true; -let scores = JSON.parse(localStorage.getItem('ticTacToeScores')) || { x: 0, o: 0, draws: 0 }; +let scores = (JSON.parse(localStorage.getItem('ticTacToeScores') ?? "null") ?? null) || { x: 0, o: 0, draws: 0 }; // Winning combinations const winningConditions = [