SparkJS Logo
HomeBeginnerGuess the Number

🎯 Guess the Number

Test your guessing skills! Can you find the secret number?

⏱️ 1 hour⚡ Beginner🎮 Game Project

Select Difficulty:

🤔
Attempts: 0 / 10
Attempts Used10 left

🎯 How to Play

  • 1.Choose your difficulty level
  • 2.Enter a number and click "Make Guess"
  • 3.Follow the hints to find the secret number
  • 4.Win before you run out of attempts!

📊 Statistics

Games Played:0
Games Won:0
Win Rate:0.0%
Attempts:0

📜 Guess History

No guesses yet. Start guessing!

💡 What You'll Learn

🎲 Random Numbers

Generate random target numbers within different ranges based on difficulty.

// Generate random 1-100
let target = Math.floor(
  Math.random() * 100
) + 1;

🔀 Conditional Logic

Use if/else statements to compare guesses and provide smart hints.

if (guess === target) {
  return "Correct!";
} else if (guess < target) {
  return "Too low!";
}

💭 User Input

Handle user input, validate numbers, and respond with keyboard events.

// Validate input
let guess = parseInt(input);
if (isNaN(guess)) {
  alert("Invalid!");
}

🎮 Game State

Track game status, attempts, history, and win/lose conditions.

// Track game state
let status = 'playing';
let attempts = 0;
let history = [];

🚀 Challenge: Enhance This Game!

Try adding these features to level up your skills:

⏱️ Timer Mode

Add a countdown timer for extra challenge!

🏆 High Score

Track the fewest attempts needed to win!

🎵 Sound Effects

Add sounds for correct/wrong guesses!

📊 Statistics Chart

Show guess distribution in a visual chart!