Skip to content

Initial PR#179

Open
verydecent wants to merge 6 commits into
bloominstituteoftechnology:masterfrom
verydecent:master
Open

Initial PR#179
verydecent wants to merge 6 commits into
bloominstituteoftechnology:masterfrom
verydecent:master

Conversation

@verydecent

Copy link
Copy Markdown

No description provided.

@gooseandmegander

Copy link
Copy Markdown

Thanks for the PR.

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

Thanks, Wonjae! I've left some comments for you to review.

Comment thread assignments/callbacks.js
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If you don't return this value, it will log out as undefined.

Comment thread assignments/callbacks.js
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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?

Comment thread assignments/callbacks.js

function sumNums(x, y, cb) {
// sumNums adds two numbers (x, y) and passes the result to the callback.
cb(x, y);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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?

Comment thread assignments/callbacks.js
}
}

contains('Pencil', items, listChecker);

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No need for +=, + works here because the reducer method is already aggregating the results of the return.

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