Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions assignments/array-methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const loopFullName = (item, index) =>{
fullName.push(`${item.first_name} ${item.last_name}`);
return fullName;
}

runners.forEach(loopFullName);
console.log(fullName);

Expand Down Expand Up @@ -89,13 +88,25 @@ console.log(largeShirts);
// ==== Challenge 4: Use .reduce() ====
// 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
let ticketPriceTotal = [];
console.log(ticketPriceTotal);
const eachTicketPrice = (item) => {
ticketPriceTotal.push(item.donation);
// console.log(item.donation);
return ticketPriceTotal;
}

const runnersDonation = runners.forEach(eachTicketPrice);
// console.log(ticketPriceTotal);
const total = ticketPriceTotal.reduce((total, amount) => total + amount);
console.log(`The total donation amount is \$${total}`);
// response.reduce(calcTotalDonation);
// console.log(ticketPriceTotal);

// ==== Challenge 5: Be Creative ====
// 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 solve 3 unique problems using one or many of the array methods listed above.

// Problem 1

// Problem 2

// Problem 3
// Problem 1/2/3
console.log(`* Problems I could solve \n
** Get records of all users but a specific key/value or combined such as Fullname \n
** Pull specific records from one object to another, such as passing multiple users under the same subscription \n
** Combine two objects and return a single object, more like a SQL join of two columns and tables. \n
** Search and return page/objects it is referring to.`)