Debugging#264
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the number guessing game logic to resolve prior bugs and make game state updates (messages, reset, attempts) more consistent during play.
Changes:
- Refactors message handling by introducing a corrected
hideAllMessages()implementation. - Fixes and simplifies game reset via
setup()(attempts reset, inputs re-enabled, messages/reset hidden). - Improves guess handling with range validation, pluralization for “guess/guesses”, and correct too-high/too-low/max-attempt outcomes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| const remainingAttempts = maxNumberOfAttempts - attempts; | ||
| // Checks the player's guess and updates the visible game messages. | ||
| function checkGuess() { | ||
| const guess = parseInt(guessInput.value, 10); |
There was a problem hiding this comment.
parseInt() will coerce non-integer inputs like "1.9" or "1e2" into an integer (1), and Number.isInteger(guess) will still pass, so users can effectively submit values they didn’t enter. Prefer converting with Number(guessInput.value) (or parseFloat) and then validating with Number.isInteger(...) before proceeding.
| const guess = parseInt(guessInput.value, 10); | |
| const guess = Number(guessInput.value); |
|
Need a pull request against your forked main, not against the Code the dream debugging repository. |
No description provided.