Mitchell Robles - JavaScript-II - #307
Conversation
John-Spraul
left a comment
There was a problem hiding this comment.
- Git stuff
- Completed assignment (we need to go over proper use of map & filter)
- Stretch problems & goal(s)
Good Work! I'd like clarify a couple things with you when you have time 👍
|
|
||
| function getLength(arr, cb) { | ||
| // getLength passes the length of the array into the callback. | ||
| cb(arr.length()); |
There was a problem hiding this comment.
don't add () when using length; it's not a function
| // 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. | ||
| let fullName = []; | ||
|
|
||
| runners.forEach((arr) => { |
There was a problem hiding this comment.
arr is a confusing name for a placeholder, since runners is not an array of arrays (it is an array of objects)
|
|
||
| runners.map((arr) => { | ||
| allCaps.push(arr.last_name.toUpperCase()); | ||
| }) |
There was a problem hiding this comment.
don't use map as a for loop, map returns an array, so your code should look like:
allCaps = runners.map((runner) => {
return runner.first_name.toUpperCase();
});
| if (arr.shirt_size === 'L' || arr.shirt_size === 'XL' || arr.shirt_size === '2XL' || arr.shirt_size === '3XL') { | ||
| largeShirts.push(arr); | ||
| } | ||
| }) |
There was a problem hiding this comment.
You're using filter as a for loop here as well, should be:
largeShirts = runners.filter(runner => {
return (runner.shirt_size === 'L' || runner.shirt_size === 'XL' || runner.shirt_size === '2XL' || runner.shirt_size === '3XL')
}
| // 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 = []; | ||
|
|
||
| const ticketPriceTotal = runners.reduce((accumulator, item) => { |
There was a problem hiding this comment.
can't declare ticketPriceTotal again, so get rid of const here
| } else { | ||
| odds.push(arr.id); | ||
| } | ||
| }) |
There was a problem hiding this comment.
you used map as a for loop again 😿
|
|
||
| runners.filter(arr => { | ||
| emails.push(arr.email); | ||
| }) |
There was a problem hiding this comment.
You used filter as a for loop, and you didn't filter anything 😭
| runners.filter(arr => { | ||
| if (arr.donation <= 100) { | ||
| embezzledFunds.push(arr.donation); | ||
| } |
There was a problem hiding this comment.
you used filter as a for loop again again 🔁 😭 😭
| const embezzledFundsTotal = embezzledFunds.reduce((accumulator, item) => { | ||
| const total = accumulator + item; | ||
| return total; | ||
| }, 0) |
Completed most assignments. I still need to finish the "creative" sections.
Sorry for the late PR.
@John-Spraul