-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguessRandomNumber js.html
39 lines (22 loc) · 989 Bytes
/
guessRandomNumber js.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
<html>
<head>
<title>Javascript</title>
</head>
<body>
<p>How many Finger I'm holding up (1 to 10)</p>
<p><input type ="text" id="guess"></p> <button id="checkGuess">Guess!</button>
<script type="text/javascript">
document.getElementById("checkGuess").onclick = function() {
var randomNumber = Math.random();
randomNumber = randomNumber * 6;
randomNumber = Math.floor(randomNumber);
if (document.getElementById("guess").value == randomNumber) {
alert ("Well done you got it!")
} else {
alert("Nope! The number was " + randomNumber);
}
}
document.getElementById()
</script>
</body>
</html>