Skip to content

Commit 0a50c09

Browse files
committed
worked on array-methods
1 parent fa46546 commit 0a50c09

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎assignments/array-methods.js‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,24 +56,35 @@ const runners = [{"id":1,"first_name":"Charmain","last_name":"Seiler","email":"c
5656
// ==== Challenge 1: Use .forEach() ====
5757
// The event director needs both the first and last names of each runner for their running bibs. Combine both the first and last names into a new array called fullName.
5858
let fullName = [];
59-
fullName.forEach(function(item, index, runners) {
60-
fullName.push(`${runner.first_name} ${runner.last_name}`)
61-
});
59+
runners.forEach((runners) => {
60+
fullName.push(`${runners.first_name} ${runners.last_name}`)
61+
}) ;
6262
console.log(fullName);
6363

6464
// ==== Challenge 2: Use .map() ====
6565
// 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
6666
let allCaps = [];
67+
runners.map((runners) => {
68+
allCaps.push(runners.first_name.toUpperCase());
69+
});
6770
console.log(allCaps);
6871

6972
// ==== Challenge 3: Use .filter() ====
7073
// 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
7174
let largeShirts = [];
75+
runners.filter((runners) => {
76+
if (runners.shirt_size == 'L') {
77+
largeShirts.push(runners);
78+
};
79+
});
7280
console.log(largeShirts);
7381

7482
// ==== Challenge 4: Use .reduce() ====
7583
// 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
7684
let ticketPriceTotal = [];
85+
runners.reduce((sum, runners) => {
86+
ticketPriceTotal = runners.donation;
87+
});
7788
console.log(ticketPriceTotal);
7889

7990
// ==== Challenge 5: Be Creative ====

‎assignments/function-conversion.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Take the commented ES5 syntax and convert it to ES6 arrow Syntax
22

3-
let myFunction = function () {};
3+
let myFunction = () => {};
44

55
let anotherFunction = param => param;
66

0 commit comments

Comments
 (0)