Bug 1: Variable shadowing in getWinner() (tic-tac-toe.js)
📝 Description
The destructured variable x shadows the game symbol string "X" used throughout the codebase.
// Current (buggy)
const [a, x, c] = WINS[idx];
if (b[a] && b[a] === b[x] && b[x] === b[c]) { ... }
This creates a silent naming collision. Any future reference to x inside
getWinner() will resolve to a board index (number), not the game symbol "X"
(string), causing unpredictable behaviour.
🔄 Steps to Reproduce
1.Inspect getWinner()
2. the middle destructured variable is named x, colliding with the "X" game symbol used in the outer scope.
🎯 Expected Behavior
The getWinner() function should check all win combinations correctly. The middle index variable should be clearly named to represent a board position, with no naming collision with the game symbol "X" used in the outer scope. Future developers should be able to safely reference X (the game symbol) inside or near getWinner() without ambiguity.
❌ Actual Behavior / Error Logs
Identified via code review and live viewing — no runtime error thrown.
The destructured variable is named x, silently shadowing the
outer constant X = "X":
💻 Environment
- OS: Windows 11
- Python Version:3.11
- File Name: tic-tac-toe.js
###Screenshot
Bug 2: Race condition in aiTurn()
📝 Description
lockBoard(false) is called before placeMove(). This creates a brief
window where all cells are unlocked and a fast human click can fire a move
simultaneously with the AI's move.
🔄 Steps to Reproduce
- Start a game vs Computer (any difficulty)
- Wait for the AI's turn
- Click a cell rapidly the moment the AI finishes its delay timer
- Both moves may register in the same frame
🎯 Expected Behavior
When it is the AI's turn, the board should remain fully locked (all cells disabled) until the AI's move has been placed on the board. Only after placeMove() completes should cells be re-enabled for the next human turn.
❌ Actual Behavior / Error Logs
Identified via code review — not yet triggered at runtime.
lockBoard(false) fires BEFORE placeMove(), creating a window where
all empty cells are clickable while the AI move is not yet placed.
💻 Environment
- OS: Windows 11
- Python Version:3.11
- File Name: tic-tac-toe.js
###Screenshot
Bug 1: Variable shadowing in
getWinner()(tic-tac-toe.js)📝 Description
The destructured variable
xshadows the game symbol string"X"used throughout the codebase.This creates a silent naming collision. Any future reference to
xinsidegetWinner()will resolve to a board index (number), not the game symbol "X"(string), causing unpredictable behaviour.
🔄 Steps to Reproduce
1.Inspect
getWinner()2. the middle destructured variable is named
x, colliding with the"X"game symbol used in the outer scope.🎯 Expected Behavior
The getWinner() function should check all win combinations correctly. The middle index variable should be clearly named to represent a board position, with no naming collision with the game symbol "X" used in the outer scope. Future developers should be able to safely reference X (the game symbol) inside or near getWinner() without ambiguity.
❌ Actual Behavior / Error Logs
Identified via code review and live viewing — no runtime error thrown.
The destructured variable is named
x, silently shadowing theouter constant X = "X":
💻 Environment
###Screenshot
Bug 2: Race condition in
aiTurn()📝 Description
lockBoard(false)is called beforeplaceMove(). This creates a briefwindow where all cells are unlocked and a fast human click can fire a move
simultaneously with the AI's move.
🔄 Steps to Reproduce
🎯 Expected Behavior
When it is the AI's turn, the board should remain fully locked (all cells disabled) until the AI's move has been placed on the board. Only after placeMove() completes should cells be re-enabled for the next human turn.
❌ Actual Behavior / Error Logs
Identified via code review — not yet triggered at runtime.
lockBoard(false) fires BEFORE placeMove(), creating a window where
all empty cells are clickable while the AI move is not yet placed.
💻 Environment
###Screenshot