-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguessno.js
39 lines (35 loc) · 1.35 KB
/
guessno.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
const number = Math.trunc(Math.random()*20) + 1;
let score = 20;
let highscore =0;
document.querySelector('.check').addEventListener
('click', function() {
const guess = Number (document.querySelector('.guess').value);
if(!guess){
document.querySelector('.message').textContent = 'ENTER THE NUM MOTHERFUCKER';
}
else if(guess === number){
document.querySelector('.message').textContent = ' U GOT IT RIGHT MOTHERFUCKER';
document.querySelector('body').style.backgroundColor = '#3cab17'
document.querySelector('.number').textContent = number;
if(score> highscore){
highscore=score;
document.querySelector('.highscore').textContent = highscore;
}
}
else if (guess > number){
document.querySelector('.message').textContent = ' TOO HIGHT U IDIOT';
document.querySelector('body').style.backgroundColor = '#ff0000'
score--;
document.querySelector('.score').textContent = score;
}
else if (guess < number){
document.querySelector('.message').textContent = ' TOO LOW U IDIOT';
document.querySelector('body').style.backgroundColor = '#ff0000'
score--;
document.querySelector('.score').textContent = score;
}
});
document.querySelector('.again').addEventListener
('click', function(){
window.location.reload("Refresh")
})