Skip to content

Commit 61a6e30

Browse files
committed
completed problem 3
1 parent 84b3a1d commit 61a6e30

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

assignments/array-methods.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ const sortLargestShirtDonor = largeShirts
499499
const logLargesetShirtDonorWhoGetsPriority = (largestDonationOfLargeShirtOwners, peopleWithShirtProblem, cb) => {
500500
// console.log(largestDonationOfThemLargeShirtOwners)
501501
// console.log(peopleWithShirtProblem);
502-
const largestShirtOwner = peopleWithShirtProblem.forEach(person => {
502+
peopleWithShirtProblem.forEach(person => {
503503
if (person.donation === largestDonationOfLargeShirtOwners) {
504504
cb(`${person.first_name} ${person.last_name} gets priority for a different shirt size because he/she donated the most: ${person.donation} Dollars.`)
505505
}
@@ -508,9 +508,26 @@ const logLargesetShirtDonorWhoGetsPriority = (largestDonationOfLargeShirtOwners,
508508

509509
const logger = function(log) {
510510
console.log(log)
511-
return log;
512511
};
513512

514513
logLargesetShirtDonorWhoGetsPriority(sortLargestShirtDonor, largeShirts, logger);
515514

516-
// Problem 3
515+
// Problem 3
516+
// Person representing company with smallest donation will be not be invited to the fund raiser next year
517+
// :(
518+
519+
const lowestDonor = runners
520+
.map(donor => donor.donation)
521+
.sort((b, a) => a - b)
522+
.reverse()[0];
523+
524+
const logPersonWhoGaveLowestDonation = (lowestDoner, runners, cb) => {
525+
runners.forEach(person => {
526+
if (person.donation === lowestDonor) {
527+
cb(`Although possibly great runners, ${person.first_name} and ${person.last_name} will not be invited next year because of a low donations: ${person.donation} Dollars.`)
528+
}
529+
})
530+
};
531+
532+
logPersonWhoGaveLowestDonation(lowestDonor, runners, logger);
533+

0 commit comments

Comments
 (0)