Conversation
|
Thanks for the PR. |
gooseandmegander
left a comment
There was a problem hiding this comment.
Thanks, Wonjae! I've left some comments for you to review.
| function getLength(arr, cb) { | ||
| // getLength passes the length of the array into the callback. | ||
| // getLength passes the length of the array into the callback. | ||
| cb(arr); |
There was a problem hiding this comment.
If you don't return this value, it will log out as undefined.
| function last(arr, cb) { | ||
| // last passes the last item of the array into the callback. | ||
| // last passes the last item of the array into the callback. | ||
| cb(lastIndex); |
There was a problem hiding this comment.
lastIndex is a function, and you are not using the argument items given to last. What do you think is going on, and how can you fix it?
|
|
||
| function sumNums(x, y, cb) { | ||
| // sumNums adds two numbers (x, y) and passes the result to the callback. | ||
| cb(x, y); |
There was a problem hiding this comment.
There's something you need to do here to get the sum to print or return to the console when you run the file. What needs to happen?
| } | ||
| } | ||
|
|
||
| contains('Pencil', items, listChecker); |
There was a problem hiding this comment.
You're currently checking if an item exists in the array and returning true if it does, but you're not returning false if the item does not exist.
| // ==== Challenge 1: Use .forEach() ==== | ||
| // 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 = []; | ||
| let fullName = runners.forEach(function(element, index) { |
There was a problem hiding this comment.
forEach returns undefined, which is why when you console.log fullName, it comes returns an array of undefined items. How would you mitigate this?
| // The event director needs to have all the runner's first names converted to uppercase because the director BECAME DRUNK WITH POWER. Convert each first name into all caps and log the result | ||
| let allCaps = []; | ||
| let allCaps = runners.map(function(x) { | ||
| x.first_name.toUpperCase(); |
There was a problem hiding this comment.
As is, this exercise is not logging out to the console. Why do you think that is?
| // The large shirts won't be available for the event due to an ordering issue. Get a list of runners with large sized shirts so they can choose a different size. Return an array named largeShirts that contains information about the runners that have a shirt size of L and log the result | ||
| let largeShirts = []; | ||
| let largeShirts = runners.filter(function(x) { | ||
| if(x.shirt_size === "L"; |
There was a problem hiding this comment.
As is, this exercise is not logging out to the console. Why do you think that is?
| // 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((reducer, runner) => { | ||
| return reducer += runner.donation; |
There was a problem hiding this comment.
No need for +=, + works here because the reducer method is already aggregating the results of the return.
No description provided.