Hello everybody! 👋
✨ Welcome to the Guess My Number game! This game is a simple JavaScript-based guessing game where players attempt to guess a randomly generated number within a specified range. Guess My Number is a classic game designed to entertain and challenge players of all ages. The objective of the game is to correctly guess the hidden number, which is randomly generated by the computer. Players can input their guesses and receive feedback on whether their guess is too high, too low, or correct.
The Guess My Number game is built using the following technologies:
- HTML5: Used for structuring the webpage content and layout.
- CSS3: Used for styling the game interface, including colors, typography, and layout.
- JavaScript: Used for implementing the game logic, including random number generation, user input handling, and feedback generation.
While working on this project, I learned:
- How to structure HTML documents effectively.
- How to use CSS to style and layout web pages.
- Techniques for creating responsive designs using media queries.
- Best practices for organizing and commenting code.
const displayMessage = function (message) {
document.querySelector(".message").textContent = message;
};
displayMessage("Start guessing...");
document.querySelector("body").style.backgroundColor = "#222";
document.querySelector(".number").style.width = "15rem";
document.querySelector(".guess").value = "";
document.querySelector(".number").textContent = "?";
});
The Guess My Number game offers the following features:
- Random Number Generation: The computer generates a random number within a specified range, which serves as the target for players to guess.
- User Input: Players can input their guesses using a text input field.
- Feedback: After each guess, players receive feedback on whether their guess is too high, too low, or correct.
- Win/Lose Condition: The game ends when the player correctly guesses the number or exhausts all attempts, with appropriate messages displayed for each outcome.
To play the Guess My Number game:
- Open the
index.html
file in your web browser. - Specify the range of numbers within which the hidden number will be generated.
- Input your guess in the provided text input field and submit it.
- Receive feedback on whether your guess is too high, too low, or correct.
- Continue guessing until you correctly guess the hidden number or exhaust all attempts.
- Jonas Schmedtmann
- Tuğçe Çifci - @tucecifci
- Frontend Mentor - @tucecifci