Skip to content

amirsafa2024/guess-number-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Number Guessing Game

A simple, fun, and interactive front-end only number guessing game built using HTML, CSS, and JavaScript.

The game randomly selects a secret number between 1 and 20 (inclusive). You have 4 guesses to find it. After each guess, you'll get feedback:

  • "Too high!" if your guess is higher than the secret number
  • "Too low!" if your guess is lower
  • "Congratulations! You win!" if you guess correctly

If you run out of guesses, the game reveals the secret number and you lose.

Perfect for beginners learning JavaScript or anyone looking for a quick browser game!

Persistent Stats with LocalStorage

Your progress is saved directly in your browser using LocalStorage:

  • Total games played
  • Total games won

These stats persist across sessions — close the tab or browser, come back later, and your record is still there!

Features

  • Pure vanilla JavaScript (no external libraries)
  • Responsive and clean UI
  • Random number generation (1–20)
  • 4 guesses per game with real-time feedback
  • Win/lose conditions
  • Restart game button
  • Stats tracking: games played & wins saved via LocalStorage
  • Input validation (only numbers 1–20 accepted)

Technologies Used

  • HTML5
  • CSS3 (for styling and layout)
  • Vanilla JavaScript (no external libraries)

How to Play Locally

  1. Clone or download this repository:

    git clone https://github.com/amirsafa2024/guess-number-game.git
  2. Navigate to the project folder:

    cd  THE-REPO-FOLDER
  3. Open index.html in your favorite web browser:

    • Double-click the file, or
    • Right-click → Open with → Browser
  4. Start guessing!

Contributing

Feel free to fork this repository and submit pull requests for improvements, such as:

  • Better UI/UX design
  • Additional features (e.g., difficulty levels, score tracking)
  • Bug fixes

Enjoy the game! If you like it, give this repo a ⭐!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published