-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
53 lines (44 loc) · 1.16 KB
/
script.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function userPrompt(user){
while(!user){
user;
}
document.write("<p>Hello, " + user + "!<p>");
}
function favoriteCountry(){
let favCountry;
while(!favCountry){
favCountry = prompt("What is your favorite country?");
}
document.write("<p>" + user + "'s favorite country: " + favCountry + ".<p>");
}
function y_or_n(){
let y_or_n;
while(!y_or_n || y_or_n != 'y' && y_or_n != 'n') {
y_or_n = prompt("Looking for great prices? y/n");
}
if(y_or_n === 'y') {
document.write("<p>Check out <a href='https://expedia.com' target='_blank'>Expedia</a> for great travel deals!</p>");
} else {
document.write('<p>OK, maybe next time. :)</p>');
}
}
function review(){
let rating;
let count = 0;
while(!rating || rating > 5){
rating = parseInt(prompt("Rate us! 1 - 5"));
}
do{
document.write('<img src="800px-Empty_Star.png">');
count++;
}while(count < rating)
document.write("<p>Our rating is " + rating + "/5 stars!</p>");
}
let user;
while(!user){
user = prompt("What is your name?");
}
userPrompt(user);
favoriteCountry();
y_or_n();
review();