forked from redgold7/guessing_game
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.html
29 lines (29 loc) · 1.04 KB
/
game.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
<script>
(function() {
var answers1 = ['yankees','nyy','the yankees','the new york yankees','new york yankees','yanks'];
var answers2 = [27];
var guess1 = prompt('Which baseball team has won the most World Series?', 'Type answer here');
var guess2 = prompt('How many championships have they won?', 'Type answer here');
var correct = false;
for (var i = 0; i < answers1.length; i++) {
if (guess1.toLowerCase() === answers1[i])
{ correct = true;
alert('Correct! Damn Yankees!');
break;
}
if ( !correct ) {
guess1 = prompt('Guess again!', 'Type answer here');
}
};
while (true) {
if (guess2 === answers2) {
alert('Good job!');
break;
} else if (guess2 < answers2) {
guess2 = Number.parseInt(prompt('They\'re better than that!'));
} else if (guess2 > answers2) {
guess2 = Number.parseInt(prompt('They\'re not THAT good!'));
}
}
})();
</script>