-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
87 lines (70 loc) · 1.76 KB
/
Copy pathmain.js
File metadata and controls
87 lines (70 loc) · 1.76 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
/*
...........YOUR MISSION...........
Make me a sandwich.
1. Create a Sandwich object.
2. Create 6 keys on the object all defaulted to a value of false
a. pickle: false
b. lettuce: false
c. tomato: false
d. ketchup: false
e. mustard: false
f. mayo: false
3. Create different functions where each one can change the value of only one of the keys on a Sandwich object to "true".
4. Create a function named "makeMeASandwich".
5. That function should take 6 arguments - one for each condiment on the sandwich.
6. If any of those 6 argument values are true, put that condiment on the sandwich.
7. Write to the document something like this...
"My sandwich has pickle, ketchup, mustard on it"
*/
var sandwich = {
pickle: false,
lettuce: false,
tomato: false,
ketchup: false,
mustard: false,
mayo: false,
};
function firstPickle() {
sandwich.pickle = true;
}
function firstLettuce() {
sandwich.lettuce = true;
}
function firstTomato() {
sandwich.tomato = true;
}
function firstKetchup() {
sandwich.ketchup = true;
}
function firstMustard() {
sandwich.mustard = true;
}
function firstMayo() {
sandwich.mayo = true;
}
function makeMeASandwich(pickle, lettuce, tomato, ketchup, mustard, mayo) {
var message = "My sandwich has "
if (pickle === true) {
firstPickle();
message += "pickles ";
}
if (lettuce === true) {
firstLettuce();
message += "lettuce ";
}
if (tomato === true) {
firstTomato();
message += "tomatos ";
}
if (mustard === true) {
firstMustard();
message += "mustard ";
}
if (mayo === true) {
firstMayo();
message += "mayo ";
}
document.write(message);
};
makeMeASandwich (false, true, false, true, true, true);
// console.log(sandwich);