Skip to content

Commit e49ecc8

Browse files
author
umbur
committed
completes DeclineAccept
1 parent e86f6f5 commit e49ecc8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

DeclineAccept.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Step 1:
2+
// Write a function declineEverything() that takes in an array of strings and, using .forEach(), loops through each element in the array and
3+
// calls politelyDecline() with each of them.
4+
// The .forEach() function should apply politelyDecline() directly; it should NOT merely receive argument function that uses politelyDecline().
5+
// You can test your function when you’re ready by passing in the veggies array or by making your own array!
6+
// Step 2:
7+
// Now we need to get healthy! Write a function acceptEverything() that takes in an array of strings and loops through each element in the array and
8+
// grudgingly accepts each of them, by logging to the console in the following format: 'Ok, I guess I will eat some [element].'
9+
// You can use any technique you want to accomplish this task. You can test your function when you’re ready by passing in the veggies array or
10+
// by making your own array!
11+
12+
const veggies = ["broccoli", "spinach", "cauliflower", "broccoflower"];
13+
14+
const politelyDecline = (veg) => {
15+
console.log("No " + veg + " please. I will have pizza with extra cheese.");
16+
};
17+
18+
// Write your code here:
19+
const declineEverything = (arr) => {
20+
arr.forEach(politelyDecline);
21+
};
22+
declineEverything(veggies);
23+
24+
const acceptEverything = (arr) => {
25+
arr.forEach((n) => {
26+
console.log(`Ok, I guess I will eat some ${n}.`);
27+
});
28+
};
29+
acceptEverything(veggies);

0 commit comments

Comments
 (0)