-
Notifications
You must be signed in to change notification settings - Fork 0
/
wphw2shuffle3.html
87 lines (69 loc) · 1.33 KB
/
wphw2shuffle3.html
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Number Guessing Game</title>
<style>
html {
font-family: sans-serif;
}
body {
width: 50%;
max-width: 800px;
min-width: 480px;
margin: 0 auto;
background-color: grey;
}
#myDIV {
margin: auto;
width: 300px;
height: 200px;
background: lightblue;
animation: mymove 5s infinite;
}
@keyframes mymove {
50% {background-color: orange;}
}
</style>
</head>
<body>
<div id="myDIV">
<h1>Guess The Number!</h1>
<p>Choose a Number between 1 and 10.
See if you can guess it.</p>
<div class="form">
<label for="guessArea">Enter a guess: </label>
<input type = "text" id = "guessArea" class = "guessArea">
<input type = "submit" value = "Submit guess"
class = "guessSubmit" id = "submitguess">
</div>
</div>
<script type = "text/javascript">
// random value generated
var y = Math.floor(Math.random() * 10 + 1);
// counting the number of guesses
// made for correct Guess
var guess = 1;
document.getElementById("submitguess").onclick = function(){
// number guessed by user
var x = document.getElementById("guessArea").value;
if(x == y)
{
alert("Nice! you got it in "
+ guess + " tries ");
}
else if(x > y)
// if guessed number is greater than actual number
{
guess++;
alert("Close...Try a smaller number");
}
else
{
guess++;
alert("Close...Try a bigger number")
}
}
</script>
</body>
</html>