From 77d5cab3dbbb584c5a191adf2ecf72c05e2202b3 Mon Sep 17 00:00:00 2001 From: Maneesh Raja <117005631+Maneesh2711@users.noreply.github.com> Date: Sat, 17 Jan 2026 23:54:06 +0530 Subject: [PATCH] Fix Scoreboard Issue Resolve the Score Board issue as starting from 0 instead of random score. --- Games/Candy_Crush/script.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Games/Candy_Crush/script.js b/Games/Candy_Crush/script.js index af7732fed3..00d5635208 100644 --- a/Games/Candy_Crush/script.js +++ b/Games/Candy_Crush/script.js @@ -46,6 +46,23 @@ function startGame() { } board.push(row); } + // Ensure no initial matches by checking and replacing + for (let r = 0; r < rows; r++) { + for (let c = 0; c < columns; c++) { + // Check horizontal match + if (c >= 2) { + while (board[r][c].src == board[r][c-1].src && board[r][c].src == board[r][c-2].src) { + board[r][c].src = "././assets/" + randomCandy() + ".png"; + } + } + // Check vertical match + if (r >= 2) { + while (board[r][c].src == board[r-1][c].src && board[r][c].src == board[r-2][c].src) { + board[r][c].src = "././assets/" + randomCandy() + ".png"; + } + } + } + } }