-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
70 lines (61 loc) · 1.88 KB
/
Copy pathscript.js
File metadata and controls
70 lines (61 loc) · 1.88 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const numBox = document.getElementById("numBox")
const result = document.getElementById("result")
const checkBtn = document.getElementById("checkBtn")
const newGameBtn = document.getElementById("newGameBtn")
const remChecks = document.getElementById("remChecks")
const image = document.getElementById("image")
const settings = document.getElementById("settings")
const changeChecks = document.getElementById("changeChecks")
let orgNum
let enterNum
let isStarted = false
let checks
function check(){
enterNum = numBox.value
if(isStarted == false){
result.innerHTML = "Start the game first😒"
}else if(checks === 0){
result.innerHTML = "You lose! No Problem try again😄"
updatechecks()
checkBtn.disabled = true
}
else if(enterNum != ""){
if(enterNum == orgNum){
result.innerHTML = "🎉Woohoo! You won🎉"
checkBtn.disabled = true
} else if(enterNum < orgNum){
result.innerHTML = "Try a larger number😉"
updatechecks()
} else{
result.innerHTML = "Oh! Try a smaller number😁"
updatechecks()
}
}
else{
result.innerHTML = "Where's the number?🙄"
}
}
function newGame(){
isStarted = true
checkBtn.disabled = false
orgNum = Math.floor(Math.random() * 20 + 1)
numBox.value = ""
checks = changeChecks.value
result.innerHTML = "Started....."
remChecks.innerText = "Remaining Checks : " + checks
}
function updatechecks(){
checks--
remChecks.innerText = "Remaining Checks : " + checks
}
function settingsOpen(){
if(settings.style.display === "none"){
settings.style.display = "block"
}else{
settings.style.display = "none"
}
}
function doneBtn(){
checks = changeChecks.value
newGame()
}