-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJohnsonJavaScriptExercises.js
More file actions
76 lines (50 loc) · 1.25 KB
/
JohnsonJavaScriptExercises.js
File metadata and controls
76 lines (50 loc) · 1.25 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
var total = 0;
var x = 0;
var num = prompt("Enter a Number");
for (x = 0; x <= num; x = x + 1) {
total += x;
}
console.log(total);
var stringowords = '';
var word = '';
var i = 1;
var ans = prompt("do you want to play?", "yes or no");
do {
var word = prompt("type a word");
stringowords += word;
var ans = prompt("do you want to play again?", "yes or no");
} while (ans.length == 3);
console.log(stringowords);
var phrase = 'Hello, My name is ';
var name = '';
var c = 0;
var answer = 'yes';
while(answer.length == 3) {
if (c == 0) {
var name = prompt("Hello, What is your name?");
var answer = prompt("Would you like to print your name?", "yes or no");
if (answer.length == 3) {
console.log(phrase + name);
}
}
else {
var answer = prompt("Would you like to print this again?", "yes or no");
if (answer.length == 3) {
console.log(phrase + name);
}
}
c = c + 1;
}
var breakfast = 'eggs and toast';
var lunch = 'a salad';
var dinner = 'chicken and rice';
var tod = prompt('What time of day is it?', 'Enter morning, noon, or night');
if (tod == 'morning' || tod == 'Morning') {
alert(breakfast);
}
else if (tod == 'noon' || tod == 'Noon') {
alert(lunch);
}
else if (tod == 'evening' || tod == 'Evening') {
alert(dinner);
}