"Guess My Number" is a simple number-guessing game built using HTML, CSS, and JavaScript. The user tries to guess a randomly generated number between 1 and 20. The game provides hints if the guess is too high or low, keeps track of the score, and records the high score. Features include a reset functionality and dynamic color changes based on the user's guess.
-Live Demo: https://codepen.io/harikantsharmag/pen/JjrWoaa?editors=0100
-
Random Number Generation: The game generates a random number between 1 and 20 at the start of each session.
-
Input Validation: Only numbers between 1 and 20 are accepted as valid guesses. Any out-of-range input triggers a validation message to ensure the game remains within its defined rules.
-
Dynamic Feedback: As the user guesses, the game provides feedback via text and color changes. Correct guesses turn the screen green, while incorrect guesses result in a red background.
-
Score Tracking: The score starts at 20 and decreases with each incorrect guess, motivating players to guess efficiently.
-
High Score System: The game saves and displays the highest score achieved during the session, encouraging players to improve their performance.
- Start the game and guess a number between 1 and 20.
- The game will provide feedback if your guess is too high or too low.
- You can reset the game by clicking the "Again!" button at any time.
- Try to achieve the highest score possible!
Building "Guess My Number" allowed me to deepen my understanding of how JavaScript interacts with the Document Object Model (DOM) and how web applications can respond dynamically to user actions. It helped me sharpen my problem-solving skills and understand game logic implementation.
- HTML
- CSS
- JavaScript
- Clone the repository:
git clone https://github.com/yourusername/guess-my-number.git
- Open index.html in your web browser to play the game.
Feel free to explore, modify, and enhance the game! Contributions are welcome. This project is licensed under the MIT License - see the LICENSE file for details.