-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
53 lines (48 loc) · 2.12 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"use strict";
let main_number = Math.trunc(Math.random() * 20) + 1;
let score = 20;
let high_score = 0;
document.querySelector(".check").addEventListener("click", function () {
const input_value = Number(document.querySelector(".input_number").value);
if (!input_value) {
document.querySelector(".first_comment").textContent = "No Number!!! 😂🚫";
} else if (input_value == main_number) {
document.querySelector(".first_comment").textContent =
"Congratulation... 🥳👌";
document.querySelector(".all_over").style.backgroundColor = "#009933";
if (score > high_score) {
high_score = score;
document.querySelector(".hi_fi").textContent = score;
}
document.querySelector(".hidden_number").textContent = main_number;
} else if (input_value > main_number) {
if (score > 1) {
document.querySelector(".first_comment").textContent = "Too High!!! 🙄🥱";
score--;
document.querySelector(".score_result").textContent = score;
} else {
document.querySelector(".first_comment").textContent =
"You lost the game 🤣😂";
document.querySelector(".score_result").textContent = 0;
}
} else if (input_value < main_number) {
if (score > 1) {
document.querySelector(".first_comment").textContent = "Too Low!!! 😒🤦♂️";
score--;
document.querySelector(".score_result").textContent = score;
} else {
document.querySelector(".first_comment").textContent =
"You lost the game 🤣😂";
document.querySelector(".score_result").textContent = 0;
}
}
});
document.querySelector(".button_1").addEventListener("click", function () {
score = 20;
main_number = Math.trunc(Math.random() * 20) + 1;
document.querySelector(".first_comment").textContent ="Start guessing ... ✌️✌️";
document.querySelector(".hidden_number").textContent = "?";
document.querySelector(".score_result").textContent = score;
document.querySelector(".input_number").value = "";
document.querySelector(".all_over").style.backgroundColor = "#77773c";
});