Skip to content

Commit d461973

Browse files
committed
Finished most of assignment. Working on last few problems.
1 parent 4b60da6 commit d461973

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ With some basic JavaScript principles in hand, we can now expand our skills out
2424

2525
This task focuses on getting practice with higher order functions and callback functions by giving you an array of values and instructions on what to do with that array.
2626

27-
* [ ] Review the contents of the [callbacks.js](assignments/callbacks.js) file. Notice you are given an array at the top of the page. Use that array to aid you with your functions.
27+
* [x] Review the contents of the [callbacks.js](assignments/callbacks.js) file. Notice you are given an array at the top of the page. Use that array to aid you with your functions.
2828

29-
* [ ] Complete the problems provided to you but skip over stretch problems until you are complete with every other JS file first.
29+
* [x] Complete the problems provided to you but skip over stretch problems until you are complete with every other JS file first.
3030

3131
## Task 3: Array Methods
3232

3333
Use `.forEach()`, `.map()`, `.filter()`, and `.reduce()` to loop over an array with 50 objects in it. The [array-methods.js](assignments/array-methods.js) file contains several challenges built around a fundraising 5K fun run event.
3434

35-
* [ ] Review the contents of the [array-methods.js](assignments/array-methods.js) file.
35+
* [x] Review the contents of the [array-methods.js](assignments/array-methods.js) file.
3636

3737
* [ ] Complete the problems provided to you but skip over stretch problems until you are complete with every other JS file first.
3838

‎assignments/array-methods.js‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,23 @@ console.log(allCaps);
7474
// ==== Challenge 3: Use .filter() ====
7575
// The large shirts won't be available for the event due to an ordering issue. Get a list of runners with large sized shirts so they can choose a different size. Return an array named largeShirts that contains information about the runners that have a shirt size of L and log the result
7676
let largeShirts = [];
77+
78+
runners.filter((runner) => {
79+
if (runner.shirt_size === 'L') {
80+
largeShirts.push(runner);
81+
}
82+
});
83+
7784
console.log(largeShirts);
7885

7986
// ==== Challenge 4: Use .reduce() ====
8087
// The donations need to be tallied up and reported for tax purposes. Add up all the donations into a ticketPriceTotal array and log the result
81-
let ticketPriceTotal = [];
88+
// let ticketPriceTotal = [];
89+
90+
let ticketPriceTotal = runners.reduce((total, runner) => {
91+
return total + runner.donation;
92+
}, 0);
93+
8294
console.log(ticketPriceTotal);
8395

8496
// ==== Challenge 5: Be Creative ====

‎assignments/closure.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
// ==== Challenge 1: Write your own closure ====
22
// Write a simple closure of your own creation. Keep it simple!
33

4+
function britishEmpire() {
5+
const kingGeorgeSaid = "I'm really glad we colonized America";
6+
console.log(kingGeorgeSaid);
7+
8+
function americanColonies() {
9+
const benFranklinSaid = "We don't need the British. We can have our own country.";
10+
console.log(benFranklinSaid);
11+
}
12+
13+
americanColonies()
14+
}
15+
16+
britishEmpire()
417

518
/* STRETCH PROBLEMS, Do not attempt until you have completed all previous tasks for today's project files */
619

0 commit comments

Comments
 (0)