Skip to content

Mitchell Robles - JavaScript-II - #307

Open
mitchellr92 wants to merge 5 commits into
bloominstituteoftechnology:masterfrom
mitchellr92:master
Open

Mitchell Robles - JavaScript-II#307
mitchellr92 wants to merge 5 commits into
bloominstituteoftechnology:masterfrom
mitchellr92:master

Conversation

@mitchellr92

Copy link
Copy Markdown

Completed most assignments. I still need to finish the "creative" sections.

Sorry for the late PR.

@John-Spraul

@John-Spraul John-Spraul left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 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 👍

Comment thread assignments/callbacks.js

function getLength(arr, cb) {
// getLength passes the length of the array into the callback.
cb(arr.length());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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());
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
}
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't declare ticketPriceTotal again, so get rid of const here

} else {
odds.push(arr.id);
}
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you used map as a for loop again 😿


runners.filter(arr => {
emails.push(arr.email);
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You used filter as a for loop, and you didn't filter anything 😭

runners.filter(arr => {
if (arr.donation <= 100) {
embezzledFunds.push(arr.donation);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you used filter as a for loop again again 🔁 😭 😭

const embezzledFundsTotal = embezzledFunds.reduce((accumulator, item) => {
const total = accumulator + item;
return total;
}, 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job using reduce 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants