Skip to content

Bryce Evans#175

Open
BryceEvans wants to merge 4 commits into
bloominstituteoftechnology:masterfrom
BryceEvans:master
Open

Bryce Evans#175
BryceEvans wants to merge 4 commits into
bloominstituteoftechnology:masterfrom
BryceEvans:master

Conversation

@BryceEvans

Copy link
Copy Markdown

No description provided.

@TERR1E TERR1E 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.

@dtacheny dtacheny 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.

Good work! Your code is easy to organized and easy to read. Let me know if you need any more clarification on closure/array functions.

Comment thread assignments/array-methods.js Outdated
// ==== 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 = [];
let ticketPriceTotal = runners.reduce(function(donation, runners) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Line 82: This would be correct if you pass in an initial value, like you did on line 88!

ticketPTotal is also correct, but you are adding each runner's donation to total while total is never defined.

Comment thread assignments/array-methods.js Outdated

let matchedDonations = [];

runners.filter((runners) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm not sure filter is the best use for what this is trying to accomplish, though I like how you approached the problem. Filter is good for excluding elements from an array while the remaining elements stay the same. I would use .filter to get an array of only Wordtune employees, then use .map or .forEach to get the array of Wordtune employees + their donations.

Here's an example. Let's say I have a list of numbers, 1-10. I want a list of all the even numbers multiplied by 2.

const numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];

const onlyEvenNumbers = numbers.filter(function(number) {
  return number % 2 === 0            // this checks if number is evenly divisible by 2
})

console.log(onlyEvenNumbers);    // this logs out [2, 4, 6, 8, 10]

const doubledEvenNumbers = onlyEvenNumbers.map(function(number) {
  return number * 2;
})

console.log(doubledEvenNumbers);    // this logs out [4, 8, 12, 16, 20]

See how you could approach this problem in the same way.

Comment thread assignments/closure.js
let character = 'Ironman'
function characterSpeak() {
return 'I am ' + character + '!';
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Think about what would happen if character were inside this function. Would you be able to do console.log(character), outside of the function? Like on line 7?

Right now character has global scope, meaning that you could access it from anywhere in your code. What would change if it were confined to the scope of the function characterSpeak?

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.

3 participants