-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguess.html
More file actions
58 lines (55 loc) · 2.13 KB
/
guess.html
File metadata and controls
58 lines (55 loc) · 2.13 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
58
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
<head>
<title>Gussing Game</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<LINK rel="stylesheet" type="text/css" href="css/style.css">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="css/base.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,300,400">
</head>
<body>
<header class="container">
<h1>
Guessing Game
</h1>
</header>
<p></p>
<div class="container">
Let's Play
</div>
<script>
var numberRan = Math.ceil(Math.random() * 100);
var guess = -1;
var numGuess = 0;
while (guess != numberRan) {
// Game code goes here
var guess = prompt("Guess a number between 1 - 100 or hit cancel to stop playing");
if (guess === null) {
break;
}
else if (guess >= 1 && guess <= 100) {
// Now check the difference
if(numberRan > guess){
numGuess++;
alert("The number is higher then " + guess + ". That was guess (" + numGuess + ")");
} else if(numberRan < guess){
numGuess++;
alert("The number is lower then " + guess + ". That was guess (" + numGuess + ")");
} else if(numberRan == guess){
numGuess++;
alert("Good job! The answer was " + numberRan + " It took you " + numGuess + " guesses.");
break;
}
}
}
alert("The answer was " + numberRan);
</script>
</body>
</html>