Skip to content

Commit 8a8fc45

Browse files
committed
arrow function done and challenge 3 done
1 parent ba45e24 commit 8a8fc45

2 files changed

Lines changed: 17 additions & 17 deletions

File tree

assignments/array-methods.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,17 @@ 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+
largeShirts = runners.filter(function(runner) {
78+
return runner.shirt_size === "L";
79+
})
7780
console.log(largeShirts);
7881

7982
// ==== Challenge 4: Use .reduce() ====
8083
// 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
8184
let ticketPriceTotal = [];
85+
ticketPriceTotal = runners.reduce(function(runner) {
86+
return runner['donation'];
87+
})
8288
console.log(ticketPriceTotal);
8389

8490
// ==== Challenge 5: Be Creative ====
Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
// Take the commented ES5 syntax and convert it to ES6 arrow Syntax
22

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

5-
// let anotherFunction = function (param) {
6-
// return param;
7-
// };
5+
let anotherFunction = param => param;
86

9-
// let add = function (param1, param2) {
10-
// return param1 + param2;
11-
// };
12-
// add(1,2);
7+
let add = (param1, param2) => param1 + param2;
138

14-
// let subtract = function (param1, param2) {
15-
// return param1 - param2;
16-
// };
17-
// subtract(1,2);
9+
add(1,2);
1810

19-
// exampleArray = [1,2,3,4];
20-
// const triple = exampleArray.map(function (num) {
21-
// return num * 3;
22-
// });
23-
// console.log(triple);
11+
let subtract = (param1, param2) => param1 - param2;
12+
13+
subtract(1,2);
14+
15+
exampleArray = [1,2,3,4];
16+
const triple = exampleArray.map(num => num * 3);
17+
console.log(triple);

0 commit comments

Comments
 (0)