-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
32 lines (29 loc) · 1.23 KB
/
app.js
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
function askQuestion(promptText, yesAnswer, yesAnswerOutput,noAnswer, noAnswerOutput) {
let response = prompt(promptText);
if (response !== null) {
if (response.toLowerCase()=== yesAnswer) {
alert(yesAnswerOutput);
} else if (response.toLowerCase() === noAnswer) {
alert(noAnswerOutput);
} else {
alert('Invalid response. Please answer \'yes\' or \'no\'.');
}
}
}
askQuestion('Are mangoes your favorite fruit?', 'yes', 'Great! Mangoes are delicious.', 'no', 'That\'s alright. Mangoes may not be for everyone.')
askQuestion('Did you know there are almost 300 different types of mangoes?', 'yes','You\'re a mango expert!','no','Don\'t worry! You can learn new things everyday.')
function askNumber() {
let number = prompt('How many different mangoes have you tried?');
console.log(typeof(number))
while(!number) {
number = prompt('Please enter how many types of mangoes you\'ve tried.')
}
alert('Wow, you\'ve tried ' + number + ' types of mangoes!')
return number
}
let number = parseInt(askNumber())
console.log(typeof(number));
for (let i = 0; i < number; i++) {
console.log(i)
document.write('<img src="https://florigen.co.ke/wp-content/uploads/fruit-mango-kent-02.jpg">')
}