Skip to content
This repository was archived by the owner on Aug 31, 2019. It is now read-only.

completedhw#45

Closed
sarafritz88 wants to merge 1 commit intobloominstituteoftechnology:masterfrom
sarafritz88:master
Closed

completedhw#45
sarafritz88 wants to merge 1 commit intobloominstituteoftechnology:masterfrom
sarafritz88:master

Conversation

@sarafritz88
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Contributor

@seanchen1991 seanchen1991 left a comment

Choose a reason for hiding this comment

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

Looks good for the most part. I would suggest that you try to keep your indentation consistent throughout your code. In some places you indent by 4 spaces, but most of the time you indent by 2 spaces. Pick one and stick with it.

// Combine all elements into a single value going from left to right.
// Elements will be passed one by one into `cb`.
// `memo` is the starting value. If `memo` is undefined then make `elements[0]` the initial value.
if (memo === undefined) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can just do if (!memo) here.

// If `cb` returns `true` then return that element.
// Return `undefined` if no elements pass the truth test.
for (let i = 0; i < elements.length; i++) {
if (cb(elements[i]) === true) return elements[i];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can just do if (cb(elements[i])) to check for truthiness.

// Return an empty array if no elements pass the truth test
const newArr = [];
for (let i = 0; i < elements.length; i++) {
if (cb(elements[i]) === true) newArr.push(elements[i]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same thing here.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants