Skip to content

Commit 48f7051

Browse files
committed
few stretch goals completed
1 parent dca2810 commit 48f7051

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

assignments/array-methods.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,16 @@ console.log(
497497
// ==== Challenge 5: Be Creative ====
498498
// Now that you have used .forEach(), .map(), .filter(), and .reduce(). I want you to think of potential problems you could solve given the data set and the 5k fun run theme. Try to create and then solve 3 unique problems using one or many of the array methods listed above.
499499

500-
// Problem 1
500+
// Problem 1 Company each runner represents
501+
let companyArray = runners.map(runner => runner.company_name);
502+
console.log(companyArray);
501503

502504
// Problem 2
503-
505+
let largeDonation = [];
506+
runners.forEach(runner => {
507+
if (runner.donation > 100) {
508+
largeDonation.push(runner);
509+
}
510+
});
511+
console.log(largeDonation);
504512
// Problem 3

assignments/closure.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,19 @@ console.log(newCounter()); // 2
4343
/* STRETCH PROBLEM, Do not attempt until you have completed all previous tasks for today's project files */
4444

4545
// ==== Challenge 3: Create a counter function with an object that can increment and decrement ====
46-
const counterFactory = () => {
46+
const counterFactory = x => {
4747
// Return an object that has two methods called `increment` and `decrement`.
4848
// `increment` should increment a counter variable in closure scope and return it.
4949
// `decrement` should decrement the counter variable and return it.
50+
let counter = x;
51+
return function(increment = 0, decrement = 0) {
52+
counter += increment;
53+
counter -= decrement;
54+
55+
return counter;
56+
};
5057
};
58+
59+
let newCounterFactory = counterFactory(10);
60+
console.log(newCounterFactory(0, 1));
61+
console.log(newCounterFactory(1, 0));

0 commit comments

Comments
 (0)