-
Notifications
You must be signed in to change notification settings - Fork 0
/
guess-the-number.html
41 lines (35 loc) · 1.51 KB
/
guess-the-number.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
<html>
<head>
<title>Guess the Number!</title>
</head>
<body>
<label>Pick a Number from 1-100:</label>
<label id="response"></label>
<br />
<input id="user-input" type="text" />
<input id="submit-button" type="button" value="Guess" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
$('#response').text('Hi there!');
$('#submit-button').on('click', function (e) {
var input = $('#user-input').val();
alert('You typed in: ' + input);
});
// var secretNumber = parseInt(Math.random() * 100, 10) + 1;
// var userNumber = prompt("Pick a number between 1 and 100.");
// var compareNumbers = function (secretNumber, userNumber) {
// if (userNumber < secretNumber) {
// userNumber = prompt("Pick a higher number.");
// compareNumbers(secretNumber, userNumber)
// } else if (userNumber > secretNumber) {
// userNumber = prompt("Pick a lower number.");
// compareNumbers(secretNumber, userNumber)
// } else {
// console.log("You picked the correct number!");
// }
// };
// var compareNumbers = function (secretNumber, userNumber) {if (userNumber < secretNumber) {userNumber = prompt("Pick a higher number.");compareNumbers(secretNumber, userNumber)} else if (userNumber > secretNumber) {userNumber = prompt("Pick a lower number.");compareNumbers(secretNumber, userNumber)} else {console.log("You picked the correct number!");}};
// compareNumbers(secretNumber, userNumber);
</script>
</body>
</html>