Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request]: Validation for non-numeric input in script.js in guessing number #972

Closed
1 task done
tamannaaaaa opened this issue Aug 7, 2023 · 2 comments
Closed
1 task done
Assignees
Labels
enhancement New feature or request gssoc23 GirlScript summer of code level1 easy

Comments

@tamannaaaaa
Copy link
Contributor

How would you like to enhance the existing project.

In the checkGuess() function, you check if the guessedNumber is a valid number between 1 and 100. However, you don't handle cases where the input is not a number at all. When the user enters a non-numeric value (e.g., letters or symbols) in the input field, the parseInt() function will return NaN, and the game will not provide a useful error message. You may want to add validation to handle non-numeric input gracefully.

Describe breifly how would you implement the same.

To fix the validation issue, you can modify the checkGuess() function. This change ensures that the player receives an error message when they input non-numeric values. Additionally, I've moved the attempts++ statement to all branches of the conditional statement to ensure the attempts are incremented appropriately.

Are you contributing for a program?

GSSoC23

Code of Conduct

@tamannaaaaa tamannaaaaa added the enhancement New feature or request label Aug 7, 2023
@panwar8279 panwar8279 added gssoc23 GirlScript summer of code level1 easy labels Aug 8, 2023
@panwar8279
Copy link
Collaborator

Hi @tamannaaaaa , I have assigned this task to you. Kindly complete this within 2 days. Good luck!

@tamannaaaaa
Copy link
Contributor Author

Hi @panwar8279 . I have done it it's the PR #1003 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request gssoc23 GirlScript summer of code level1 easy
Projects
None yet
Development

No branches or pull requests

2 participants