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+)

๐Ÿงฑ Play Number Picker