-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
28 lines (21 loc) · 836 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Math.random();
const randomNumber = Math.floor(Math.random() * 101);
const guessInput = document.getElementById("Input");
const guessButton = document.getElementById("Button");
const feedback = document.getElementById("feedback");
const celebration = document.getElementById("celebration");
guessButton.addEventListener("click", () => {
const userGuess = parseInt(guessInput.value);
if (userGuess === randomNumber) {
feedback.textContent = "Klasse! Du gættede rigtigt!";
celebration.style.display = "block"; // Display celebration animation
} else if (userGuess < randomNumber) {
feedback.textContent = "Forkert! for lavt.";
} else {
feedback.textContent = "Forkert! for højt.";
}
});
guessInput.addEventListener("input", () => {
feedback.textContent = "";
celebration.style.display = "none";
});