Skip to content

Introduce off-by-one bug: allows 7 guesses instead of 6 - #3

Open
Copilot wants to merge 1 commit into
mainfrom
copilot/introduce-guess-bug
Open

Introduce off-by-one bug: allows 7 guesses instead of 6#3
Copilot wants to merge 1 commit into
mainfrom
copilot/introduce-guess-bug

Conversation

Copilot AI commented Aug 6, 2026

Copy link
Copy Markdown

Introduces a bug where the guess list array and loss condition are both off by one, allowing players to make 7 guesses instead of the intended NUM_OF_GUESSES_ALLOWED = 6.

Changes in src/components/Game/Game.js:

  • guessList state now initialized with NUM_OF_GUESSES_ALLOWED + 1 slots (in both initial state and resetGame)
  • Loss condition changed from guessListIndex + 1 === NUM_OF_GUESSES_ALLOWED to guessListIndex + 1 === NUM_OF_GUESSES_ALLOWED + 1

Result: the game only marks itself as lost after the 7th guess, one more than the max allowed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant