-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
65 lines (50 loc) · 2.07 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
54
55
56
57
58
59
60
61
62
63
64
'use strict';
let Score=20;
let Highscore=0;
const RandomNumber=()=>{
let Num=Math.ceil(Math.random()*20)
return Num
}
let number=RandomNumber()
document.querySelector('.check').addEventListener('click',function(){
const guess=Number(document.querySelector('.guess').value)
console.log('Guess=',guess);
if(Score>1){
if(guess>number){
document.querySelector('.message').textContent='Too High🤦♂️'
Score-=1;
document.querySelector('.score').textContent=Score;
}
else if(!guess){
document.querySelector('.message').textContent='No Number⛔'
}
else if(guess<number){
document.querySelector('.message').textContent='Too Low🤷♂️'
Score-=1;
document.querySelector('.score').textContent=Score;
}
else if (guess==number){
document.querySelector('.message').textContent='Correct Number😉🎉'
if(Score>Highscore){
Highscore=Score;
document.querySelector('.highscore').textContent=Highscore
}
document.querySelector('.number').textContent=number
document.querySelector('body').style.backgroundColor='#60b347'
document.querySelector('.number').style.width='30rem'
document.querySelector('.message').style.fontSize='20px'
}}
else{
document.querySelector('.message').textContent="YOU LOST...!!!"
document.querySelector('body').style.backgroundColor='#fa8072'
}
})
document.querySelector('.again').addEventListener('click',function(){
document.querySelector('.number').textContent='?'
// console.log("You Clicked The Again Buttton")
number=RandomNumber();
document.querySelector('.score').textContent=20;
document.querySelector('.message').textContent='Again...Guess The Number...!!!'
document.querySelector('body').style.backgroundColor=' #020202'
document.querySelector('.guess').value='';
});