-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
34 lines (31 loc) · 1.19 KB
/
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
29
30
31
32
33
34
"use strict";
let secretNumber = Math.trunc(Math.random() * 20) + 1;
document.querySelector(".number").textContent = secretNumber;
let score = 20;
document.querySelector(".check").addEventListener("click", function () {
const guess = Number(document.querySelector(".guess").value);
console.log("Your have entered", guess);
if (!guess) {
document.querySelector(".message").textContent =
"Please enter a number! 🙏";
console.log("Please enter a number! 🙏");
} else if (guess === secretNumber) {
document.querySelector(".message").textContent = "🎉 Correct Number!!";
} else if (guess > secretNumber) {
if (score > 0) {
score--;
document.querySelector(".score").textContent = score;
} else {
document.querySelector(".message").textContent = "💥 You lost the game!";
}
document.querySelector(".message").textContent = "📈 Too high";
} else if (guess < secretNumber) {
if (score > 0) {
score--;
document.querySelector(".score").textContent = score;
} else {
document.querySelector(".message").textContent = "💥 You lost the game!";
}
document.querySelector(".message").textContent = "📉 Too low";
}
});