-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGTN.html
More file actions
57 lines (55 loc) · 1.52 KB
/
GTN.html
File metadata and controls
57 lines (55 loc) · 1.52 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
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Number Guessing Game</title>
<style>
body {
font-family: sans-serif;
width: 50%;
max-width: 800px;
min-width: 480px;
margin: 0 auto;
}
</style>
</head>
<body>
<h1>Guess The Number</h1>
<p>
We have selected a random number
between 1 - 100. See if you can
guess it.
</p>
<div class="form">
<label for="guessField">
Enter a guess:
</label>
<input type="text"
id="guessField"
class="guess" placeholder="please enter the number">
<input type="submit"
value="Submit"
class="guessSubmit"
id="submit">
</div>
<script type="text/javascript">
let y = Math.floor(Math.random() * 100 + 1);
let guess = 1;
document.getElementById("submit").onclick = function () {
let x = document.getElementById("guess").value;
if (x == y) {
alert("CONGRATULATIONS!!! YOU GUESSED IT RIGHT IN "
+ guess + " GUESS ");
}
else if (x > y) {
guess++;
alert("OOPS SORRY!! TRY A SMALLER NUMBER");
}
else {
guess++;
alert("OOPS SORRY!! TRY A GREATER NUMBER")
}
}
</script>
</body>
</html>