From f936e95f9d116313f067576c54d2f1e1dcbcae5e Mon Sep 17 00:00:00 2001 From: Ibrahim Al Shouli Date: Wed, 11 Feb 2026 19:04:56 +0300 Subject: [PATCH 01/13] Validate empty player names (fixes #1) --- script.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/script.js b/script.js index 43cfa50..7fe7598 100644 --- a/script.js +++ b/script.js @@ -136,8 +136,13 @@ function startGame() { const p1Name = document.getElementById('player1Name').value.trim(); const p2Name = document.getElementById('player2Name').value.trim(); - gameState.player1.name = p1Name || 'Player 1'; - gameState.player2.name = p2Name || 'Player 2'; + if (!p1Name || !p2Name) { + alert('Both player names are required!'); + return; + } + + gameState.player1.name = p1Name; + gameState.player2.name = p2Name; document.getElementById('player1Display').textContent = gameState.player1.name; document.getElementById('player2Display').textContent = gameState.player2.name; From a63654b6fde9868f9f094cd0bb1256b8da9ca0dd Mon Sep 17 00:00:00 2001 From: Ibrahim <60303471@udst.edu.qa> Date: Wed, 11 Feb 2026 19:07:03 +0300 Subject: [PATCH 02/13] Fix delete word functionality (fixes #2) --- script.js | 1 + 1 file changed, 1 insertion(+) diff --git a/script.js b/script.js index 43cfa50..d236fcc 100644 --- a/script.js +++ b/script.js @@ -112,6 +112,7 @@ function editWord(index) { function deleteWord(index) { if (confirm('Are you sure you want to delete this word?')) { + wordBank.splice(index, 1); saveWordBank(); displayWordBank(); } From 8443bf687162f5d9721e064318e625a5bac81f68 Mon Sep 17 00:00:00 2001 From: Ibrahim Al Shouli Date: Wed, 11 Feb 2026 19:11:32 +0300 Subject: [PATCH 03/13] Prevent same player names (fixes #2) --- script.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script.js b/script.js index 7fe7598..6d3f338 100644 --- a/script.js +++ b/script.js @@ -140,6 +140,10 @@ function startGame() { alert('Both player names are required!'); return; } + if (p1Name === p2Name) { + alert('Player names must be different!'); + return; + } gameState.player1.name = p1Name; gameState.player2.name = p2Name; From 66195a2e48e773f1a3183cc08b8b7512d56e37b7 Mon Sep 17 00:00:00 2001 From: Ibrahim Al Shouli Date: Wed, 11 Feb 2026 19:15:07 +0300 Subject: [PATCH 04/13] Fix score assigned to correct player (fixes #3) --- script.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/script.js b/script.js index 6d3f338..0efae51 100644 --- a/script.js +++ b/script.js @@ -294,18 +294,18 @@ function gameWon() { gameState.gameActive = false; if (gameState.currentPlayer === 1) { - gameState.player2.score += 10; - document.getElementById('score2').textContent = gameState.player2.score; - } else { gameState.player1.score += 10; document.getElementById('score1').textContent = gameState.player1.score; + } else { + gameState.player2.score += 10; + document.getElementById('score2').textContent = gameState.player2.score; } const statusDiv = document.getElementById('gameStatus'); const statusMsg = document.getElementById('statusMessage'); const winnerName = gameState.currentPlayer === 1 ? - gameState.player2.name : gameState.player1.name; + gameState.player1.name : gameState.player2.name; statusMsg.textContent = `🎉 ${winnerName} won! The word was: ${gameState.currentWord}`; statusDiv.classList.add('show', 'winner'); From b79fe2e7dc21e5de04668ec414d2e9b6ad6d9d49 Mon Sep 17 00:00:00 2001 From: Ibrahim Al Shouli Date: Wed, 11 Feb 2026 19:17:13 +0300 Subject: [PATCH 05/13] Prevent adding empty words (fixes #4) --- script.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/script.js b/script.js index 0efae51..7cfaada 100644 --- a/script.js +++ b/script.js @@ -95,6 +95,11 @@ function addWord() { const input = document.getElementById('newWord'); const word = input.value.trim().toUpperCase(); + if (!word) { + alert('Please enter a word!'); + return; + } + wordBank.push(word); input.value = ''; saveWordBank(); From b5478fcde6480328f358874a48b61905ac722a08 Mon Sep 17 00:00:00 2001 From: Ibrahim Al Shouli Date: Wed, 11 Feb 2026 19:33:08 +0300 Subject: [PATCH 06/13] Validate words contain only letters (fixes #5) --- script.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/script.js b/script.js index 7cfaada..0844625 100644 --- a/script.js +++ b/script.js @@ -100,6 +100,11 @@ function addWord() { return; } + if (!/^[A-Z]+$/.test(word)) { + alert('Words can only contain letters A-Z!'); + return; + } + wordBank.push(word); input.value = ''; saveWordBank(); From 6b75d8e617cc3e099241cb664cab732b7a7368a7 Mon Sep 17 00:00:00 2001 From: Ibrahim <60303471@udst.edu.qa> Date: Thu, 12 Feb 2026 14:53:16 +0300 Subject: [PATCH 07/13] Fix theme toggle dark mode activation (fixes #6) --- script.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index af4797a..c312d69 100644 --- a/script.js +++ b/script.js @@ -25,15 +25,19 @@ document.addEventListener('DOMContentLoaded', function() { }); function toggleTheme() { + const body = document.body; const themeIcon = document.querySelector('.theme-icon'); - if (themeIcon.textContent === '🌙') { + body.classList.toggle('dark-mode'); + + if (body.classList.contains('dark-mode')) { themeIcon.textContent = '☀️'; } else { themeIcon.textContent = '🌙'; } } + function switchTab(tabName) { const tabs = document.querySelectorAll('.tab-content'); tabs.forEach(tab => tab.classList.remove('active')); From fb8379335fec7b43ba263d17061c7b55d73680a9 Mon Sep 17 00:00:00 2001 From: Ibrahim <60303471@udst.edu.qa> Date: Thu, 12 Feb 2026 14:58:35 +0300 Subject: [PATCH 08/13] Fix lives counter calculation (fixes #7) --- script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.js b/script.js index af4797a..c7d0682 100644 --- a/script.js +++ b/script.js @@ -239,7 +239,7 @@ function updateWrongLetters() { } function updateLives() { - const livesLeft = gameState.maxWrong - gameState.wrongGuesses + 1; + const livesLeft = gameState.maxWrong - gameState.wrongGuesses; document.getElementById('livesLeft').textContent = livesLeft; } From 9c4e10290c7ed74b6c5b8dbf7d162b7bbac666a5 Mon Sep 17 00:00:00 2001 From: Ibrahim <60303471@udst.edu.qa> Date: Thu, 12 Feb 2026 15:12:06 +0300 Subject: [PATCH 09/13] Fix wrong guesses display bug (fixes #8) --- script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.js b/script.js index af4797a..7b1738b 100644 --- a/script.js +++ b/script.js @@ -234,7 +234,7 @@ function updateWrongLetters() { if (wrong.length === 0) { wrongLettersDiv.textContent = 'None yet'; } else { - wrongLettersDiv.textContent = gameState.guessedLetters.join(', '); + wrongLettersDiv.textContent = wrong.join(', '); } } From 6eb9315364e161d7a68955700d0f016f1ee46728 Mon Sep 17 00:00:00 2001 From: Ibrahim <60303471@udst.edu.qa> Date: Thu, 12 Feb 2026 15:22:49 +0300 Subject: [PATCH 10/13] Fix wrong letters display to show only incorrect guesses (fixes #3) --- script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.js b/script.js index af4797a..7b1738b 100644 --- a/script.js +++ b/script.js @@ -234,7 +234,7 @@ function updateWrongLetters() { if (wrong.length === 0) { wrongLettersDiv.textContent = 'None yet'; } else { - wrongLettersDiv.textContent = gameState.guessedLetters.join(', '); + wrongLettersDiv.textContent = wrong.join(', '); } } From 0ab837b8df3398d8d082efb159878fd22f2dc1e1 Mon Sep 17 00:00:00 2001 From: Ibrahim <60303471@udst.edu.qa> Date: Thu, 12 Feb 2026 15:28:57 +0300 Subject: [PATCH 11/13] Fix lives counter display to correctly show remaining lives (fixes #9) --- script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script.js b/script.js index 7b1738b..5787b1a 100644 --- a/script.js +++ b/script.js @@ -239,7 +239,7 @@ function updateWrongLetters() { } function updateLives() { - const livesLeft = gameState.maxWrong - gameState.wrongGuesses + 1; + const livesLeft = gameState.maxWrong - gameState.wrongGuesses; document.getElementById('livesLeft').textContent = livesLeft; } From fc2e671ce3dae86e5c32c35362f3df49f8660ffb Mon Sep 17 00:00:00 2001 From: Ibrahim <60303471@udst.edu.qa> Date: Thu, 12 Feb 2026 15:35:43 +0300 Subject: [PATCH 12/13] Fix theme toggle to properly activate dark mode (fixes #10) --- script.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/script.js b/script.js index 5787b1a..a0c02a0 100644 --- a/script.js +++ b/script.js @@ -25,8 +25,13 @@ document.addEventListener('DOMContentLoaded', function() { }); function toggleTheme() { + const body = document.body; const themeIcon = document.querySelector('.theme-icon'); + // Toggle dark-mode class on body + body.classList.toggle('dark-mode'); + + // Update icon if (themeIcon.textContent === '🌙') { themeIcon.textContent = '☀️'; } else { From e9161f245d0287421241432680011c3707a06bcb Mon Sep 17 00:00:00 2001 From: Ibrahim <60303471@udst.edu.qa> Date: Thu, 12 Feb 2026 15:42:35 +0300 Subject: [PATCH 13/13] Fix edit word to save updated value (fixes #7) --- script.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/script.js b/script.js index a0c02a0..9529a73 100644 --- a/script.js +++ b/script.js @@ -119,12 +119,13 @@ function addWord() { function editWord(index) { const newWord = prompt('Edit word:', wordBank[index]); if (newWord) { - wordBank.splice(index, 1); - saveWordBank(); - displayWordBank(); + wordBank[index] = newWord.toUpperCase(); // replace old word with new + saveWordBank(); // save updated word bank to localStorage + displayWordBank(); // refresh UI } } + function deleteWord(index) { if (confirm('Are you sure you want to delete this word?')) { wordBank.splice(index, 1);