-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
44 lines (35 loc) · 1.3 KB
/
Copy pathindex.js
File metadata and controls
44 lines (35 loc) · 1.3 KB
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
// GENERATE RANDOM NUMBERS.
const randomNumber = Math.round(Math.random() * 20)
console.log(randomNumber);
// ACTION RESET BUTTON.
const resetBtn = document.getElementById("again").addEventListener("click", ()=> {
location.reload()
})
// ATTEMPT.
const attemptCount = document.getElementById("attempt-count");
let initialScore = 0
// STATUS
let message = document.getElementById("high");
let correct = document.getElementById("correct");
// INPUT NUMBER AND CHECK BUTTON.
const inputField = document.getElementById("input-field");
const checkBtn = document.getElementById("check-btn");
let guessNumber = document.getElementById("guess-number").innerText = randomNumber;
// MANAGE SHOW HIDE.
let hide = document.querySelector(".hide");
checkBtn.addEventListener("click", () => {
attemptCount.innerText = initialScore + 1;
initialScore++
const getValue = inputField.value;
inputField.value = ""
if (getValue == guessNumber) {
message.innerText = "🎉Congratulation you got Correct number🎉"
hide.style.display = 'none'
} else if (getValue > guessNumber) {
message.innerText = "💎Its high number."
hide.style.display = 'block'
} else if (getValue < guessNumber) {
message.innerText = "💍Its low number."
hide.style.display = 'block'
}
})