Number Picker Game
๐ฎ Guess The Number Game
A fun browser-based number guessing game built with HTML, CSS, and JavaScript.
๐ Features
- Randomly generates a secret number between 1 and 20
- Score decreases with each incorrect guess
- Tracks and stores the highest score
- User feedback for:
- No input
- Too high
- Too low
- Correct guess ๐
- Game resets on clicking the โAgainโ button
๐ง Game Logic Overview
Core Functions
generateSecretNumber()
Generates a random number between 1 and 20.
const generateSecretNumber = () => Math.trunc(Math.random() * 20) + 1;
resetGame()
Resets the game state, including:
Score
Secret number
Input fields
UI styles and text
Event Listeners
โ
.check Button
Checks the user's guess.
If correct:
Displays success message
Updates UI
Sets high score if applicable
If wrong:
Shows hint ("Too high"/"Too low")
Decreases score
๐ .again Button
Resets the game to its initial state.
๐จ UI Feedback Classes
.regular โ Default theme
.win โ Green background when the correct number is guessed
๐ File Structure
guess-the-number/
โโโ index.html # HTML markup
โโโ styles.css # Optional: styling
โโโ script.js # Game logic (provided above)
๐งช How to Use
Clone the project or copy the files into your working directory.
Open index.html in a browser.
Click "Check" to guess the number.
Click "Again" to restart the game.
๐ Tech Stack
HTML5
CSS3
JavaScript (ES6+)