-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
32 lines (26 loc) · 842 Bytes
/
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
'use strict';
const guessnum=Math.floor(Math.random()*20)+1;
let score=20;
document.querySelector(".check").addEventListener("click",()=>{
console.log(guessnum)
score=score-1;
document.querySelector(".score").innerHTML=score;
let num=document.querySelector("input").value;
if(num==guessnum)
{
document.querySelector("body").style.backgroundColor="rgb(92, 228, 99)";
document.querySelector(".message").innerHTML="You Won";
document.querySelector(".highscore").innerHTML=score;
}
else if(num>guessnum)
{
document.querySelector(".message").innerHTML="Too High";
}
else{
document.querySelector(".message").innerHTML="Too Low";
}
}
)
document.querySelector(".again").addEventListener("click",()=>{
location.reload()
})