-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
133 lines (106 loc) · 4.81 KB
/
Copy pathapp.js
File metadata and controls
133 lines (106 loc) · 4.81 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
'use strict';
let userName = prompt('What is your name?');
console.log('User\'s name is ' + userName);
let correctAnswers = 0;
alert('Hello ' + userName + '! Let\'s see if you can answer these yes/no questions about me. Please type your response as either yes/no or y/n.');
//question one
let question1 = prompt('Is Lee a Swing dancer?').toLowerCase();
if (question1 === 'yes' || question1 === 'y') {
alert('That\'s right, ' + userName + '! Lee\'s been doing Lindy Hop and other Jazz dances for nine years!');
correctAnswers++;
} else {
alert('He mentioned this the first day in class during his introduction. Were you listening,' + userName + ' ? :(');
}
console.log('User\'s response is "' + question1 + '" to question 1.');
//question two
let question2 = prompt('Is Lee a smoker?').toLowerCase();
if (question2 === 'no' || question2 === 'n') {
alert('That\'s correct, ' + userName + '! Up until about a year and a half ago, he was for the prior 12 years, but he has since quit!');
correctAnswers++;
} else {
alert('That is a big negatory,' + userName + '. He used to, but does no longer.');
}
console.log('User\'s response is "' + question2 + '" to question 2.');
//question three
let question3 = prompt('Is Lee playing PokemonGO right now?').toLowerCase();
if (question3 === 'yes' || question3 === 'y') {
alert('Most likely. Probably just caught a Pikachu, ' + userName + '. Just kidding. It\'s just a Zubat. Of course.');
correctAnswers++;
} else {
alert('Interesting thought, ' + userName + '. If he\'s not playing, his phone\'s battery has likely died.');
}
console.log('User\'s response is "' + question3 + '" to question 3.');
//question four
let question4 = prompt('Is Lee\'s hair red?').toLowerCase();
if (question4 === 'no' || question4 === 'n') {
alert('Really, ' + userName + '? Have you looked at him? It\'s pretty red. :)');
} else {
alert('That\'s correct, ' + userName + '! Been a ginger his whole life.');
correctAnswers++;
}
console.log('User\'s response is "' + question4 + '" to question 4.');
//question 5
let question5 = prompt('Was he born in California?').toLowerCase();
if (question5 === 'yes' || question5 === 'y') {
alert('Yup! In a small town near Lancaster, California, ' + userName + '!');
correctAnswers++;
} else {
alert('That is incorrect, ' + userName + '. He was born in northern California ');
}
console.log('User\'s response is "' + question5 + '" to question 5.');
alert('Now for a more difficult question with a number for an answer. Do your best!');
//Question 6
let age = 31;
for (let i = 0; i < 4; i++) {
let ageAnswer = prompt('How old is Lee? Redheads are deceptively difficult to tell with!');
if (ageAnswer == age) {
alert('You got it right! Great job, partner. Lee is ' + age + '!');
console.log('User response is ' + ageAnswer + ' to question 6');
correctAnswers++;
break;
}
else if (ageAnswer > age) {
alert('You guessed a bit too high. Does he look that old?');
console.log('User response is ' + ageAnswer + ' to question ');
}
else if (ageAnswer < age) {
alert('You\'re a bit too low. I realize Lee\'s immature, but not that bad.');
console.log('User response is ' + ageAnswer + ' to question 6');
}
else if (isNaN(ageAnswer) === true) {
alert('That is not a number. You can\'t do that.');
console.log('User response is ' + ageAnswer + ' to question 6');
}
else if ((i === 3) && (ageAnswer !== age)) {
alert('You\'ve run out of chances. Lee\'s ' + age + ', for the record!');
console.log('User response is ' + ageAnswer + ' to question 6');
}
}
//Question 7
let userCorrect = false;
let pokemon = ['pikachu', 'zubat', 'drowzee', 'onyx', 'charmander', 'snorlax'];
let guesses = 0;
while (guesses < 7) {
let pokeAnswer = prompt('What Pokemon has Lee caught this week on PokemonGO?').toLowerCase();
for (let i = 0; i < pokemon.length; i++) {
if (pokeAnswer === pokemon[i]) {
alert('You caught the right answer! Nice work! The ones he caught this week are: ' + pokemon);
console.log('User response is ' + pokeAnswer + ' to question 6');
guesses = 7;
correctAnswers++;
userCorrect = true;
break;
}
}
if (guesses !== 7) {
alert('Not that one. You\'re not the very best, but try again!');
console.log('User response is ' + pokeAnswer + ' to question 6');
}
guesses++;
}
if (userCorrect === false) {
alert('Uh-Oh! You did not get any right. The Pokemon that Lee caught this week are: ' + pokemon);
console.log('User response is ' + pokeAnswer + ' to question 6');
}
alert(userName + ', you scored a total of ' + correctAnswers + ' out of 7');
console.log(userName + 'scored a total of ' + correctAnswers + ' out of 7');