-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
46 lines (33 loc) · 1.04 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
// Number to guess
let computerNumber = Math.floor(Math.random() * 100) + 1;
// Stores hint
let holdHint = document.getElementById("text-Display");
// Stores input from user
let holdValue = document.getElementById("number");
// Holds start new game
let playAgain = document.getElementById("play-Again");
// Number user is guessing
let holdGuess;
function submitVal(){
// Checks if value is truthy
if(holdValue.value){
holdGuess = parseInt(holdValue.value);
} else{
}
holdGuess = holdValue.value;
if(holdGuess < computerNumber){
holdHint.innerHTML = "Value is too Small";
} else if(holdGuess > computerNumber){
holdHint.innerHTML = "Value is too Large";
}
if(holdGuess == computerNumber){
holdHint.innerHTML = "Congrats! you won";
playAgain.style.display = "block";
}
}
function reset(){
computerNumber = Math.floor(Math.random() * 100) + 1;
playAgain.style.display = "none";
holdValue.value = "";
holdHint.innerHTML = "Number Guesser";
}