Skip to content

Commit 865b523

Browse files
committed
array-methods.js WIP
1 parent 3a6a1ca commit 865b523

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

assignments/array-methods.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,25 @@ 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+
runners.forEach(item => fullName.push(`${item.first_name} ${item.last_name}`));
5960
console.log(fullName);
6061

6162
// ==== Challenge 2: Use .map() ====
6263
// 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
6364
let allCaps = [];
65+
allCaps = runners.map(item => item.first_name.toUpperCase());
6466
console.log(allCaps);
6567

6668
// ==== Challenge 3: Use .filter() ====
6769
// 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
6870
let largeShirts = [];
71+
largeShirts = runners.filter(item => item.shirt_size === 'L');
6972
console.log(largeShirts);
7073

7174
// ==== Challenge 4: Use .reduce() ====
7275
// 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
7376
let ticketPriceTotal = [];
77+
ticketPriceTotal = runners.reduce
7478
console.log(ticketPriceTotal);
7579

7680
// ==== Challenge 5: Be Creative ====

assignments/callbacks.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ const items = ['Pencil', 'Notebook', 'yo-yo', 'Gum'];
2727

2828
function getLength(arr, cb) {
2929
// getLength passes the length of the array into the callback.
30-
let length = arr.length;
31-
cb(length);
30+
cb(arr.length);
3231
}
3332
getLength(items, (length) => {
3433
console.log(length);

0 commit comments

Comments
 (0)