Skip to content

Commit bb840ba

Browse files
committed
solution for challenge 5
1 parent bee80e7 commit bb840ba

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

‎assignments/array-methods.js‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ let fullName = [];
6060
fullName.push(`${runner.first_name} ${runner.last_name}`);
6161
});
6262

63-
console.log(fullName);
63+
//console.log(fullName);
6464

6565
// ==== Challenge 2: Use .map() ====
6666
// The event director needs to have all the runner's first names converted to uppercase because the director BECAME DRUNK WITH POWER. Convert each first name into all caps and log the result
@@ -69,28 +69,42 @@ allcaps = runners.map(runner => {
6969
return runner.first_name.toLocaleUpperCase();
7070
});
7171

72-
console.log(allCaps);
72+
//console.log(allCaps);
7373

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 = [];
7777
largeShirts = runners.filter(runner => {
7878
return runner.shirt_size.toLowerCase().indexOf(('L').toLowerCase()) > -1;
7979
});
80-
console.log(largeShirts);
80+
//console.log(largeShirts);
8181

8282
// ==== Challenge 4: Use .reduce() ====
8383
// 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
8484
let ticketPriceTotal = [];
8585
ticketPriceTotal = runners.reduce((total, currentValue) => total + currentValue.donation, 0);
8686

87-
console.log(ticketPriceTotal);
87+
//console.log(ticketPriceTotal);
8888

8989
// ==== Challenge 5: Be Creative ====
9090
// 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.
9191

9292
// Problem 1
93+
// display name of althete's working withn skinix and skinte
94+
95+
let workPlace = [];
96+
97+
runners.forEach(runner => {
98+
if((runner.company_name === 'Skinix') || (runner.company_name === 'Skinte')) {
99+
workPlace.push(`Name: ${runner.first_name} ${runner.last_name}, company: ${runner.company_name}`);
100+
}
101+
})
102+
// console.log(workPlace);
93103

94104
// Problem 2
105+
// display athletes that have made donations higher than 200;
106+
let higherDonations = [];
107+
higherDonations = runners.filter(runner => (runner.donation > 200));
108+
console.log(higherDonations);
109+
// Problem 3
95110

96-
// Problem 3

‎assignments/callbacks.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,5 @@ function removeDuplicates(array, cb) {
7171
// removeDuplicates removes all duplicate values from the given array.
7272
// Pass the duplicate free array to the callback function.
7373
// Do not mutate the original array.
74+
7475
}

0 commit comments

Comments
 (0)