From f936e95f9d116313f067576c54d2f1e1dcbcae5e Mon Sep 17 00:00:00 2001 From: Ibrahim Al Shouli Date: Wed, 11 Feb 2026 19:04:56 +0300 Subject: [PATCH 1/7] 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 2/7] 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 3/7] 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 4/7] 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 5/7] 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 6/7] 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 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 7/7] 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(', '); } }