-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScript.js
More file actions
49 lines (44 loc) · 1.14 KB
/
Script.js
File metadata and controls
49 lines (44 loc) · 1.14 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
var timer = 60;
var score = 0;
var newHitValue = 0;
function runTimer() {
var timerInterval = setInterval(function () {
if (timer > 0) {
timer--;
document.querySelector(".timer-Box").textContent = timer;
} else {
clearInterval(timerInterval);
document.querySelector(".panel-bottom").innerHTML = `<h1>Game Over</h1>`;
}
}, 1000);
}
function makeBubble() {
var clutter = "";
for (var i = 1; i <= 133; i++) {
var randNo = Math.floor(Math.random() * 10);
clutter += `<div class="bubble">
<h3>${randNo}</h3>
</div>`;
}
document.querySelector(".panel-bottom").innerHTML = clutter;
}
function hitCard() {
newHitValue = Math.floor(Math.random() * 10);
document.querySelector(".hit-val").textContent = newHitValue;
}
function increaseScore() {
score += 10;
document.querySelector("#score-box").textContent = score;
}
var listner = document.querySelector(".panel-bottom");
listner.addEventListener("click", function (dets) {
var number = Number(dets.target.textContent);
if (newHitValue === number) {
increaseScore();
makeBubble();
hitCard();
}
});
makeBubble();
runTimer();
hitCard();