Bryce Evans#175
Conversation
TERR1E
left a comment
There was a problem hiding this comment.
Hi Bryce, overall you did a great job. Your code looks clean and easily readable 💯
Here are some helpful links for you:
http://exploringjs.com/es6/ch_arrow-functions.html
dtacheny
left a comment
There was a problem hiding this comment.
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.
| // ==== 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) { |
There was a problem hiding this comment.
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.
|
|
||
| let matchedDonations = []; | ||
|
|
||
| runners.filter((runners) => { |
There was a problem hiding this comment.
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.
| let character = 'Ironman' | ||
| function characterSpeak() { | ||
| return 'I am ' + character + '!'; | ||
| } |
There was a problem hiding this comment.
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?
No description provided.