Skip to main content

Guess Game

Problem Statement

Create a program that allows the user to guess a number between 1 and 100. The program should have a simple user interface that includes an input field for the guess and a button to submit the guess. When the user clicks the button, the program should display a message indicating whether the guess is too low, low, almost, correct, high, or too high.

  • Too low: The guess is less than 10 less than the correct number.
  • Low: The guess is less than 5 less than the correct number.
  • Almost: The guess is within 5 of the correct number.
  • Correct: The guess is the correct number.
  • High: The guess is less than 5 more than the correct number.

Acceptance Criteria

  • The program should have an HTML file with the required user interface elements (input field, button) styled with CSS.
  • The program should have a JavaScript function that compares the guess to the correct number.
  • Too high: The guess is less than 10 more than the correct number.
  • When the user clicks the button, the program should compare the guess to the correct number and display a message to the user.

Hints

  • Use the Math.random() function to generate a random number between 0 and 1. i.e. Math.random()