Skip to content

WIP (Harrison Crawford)#232

Open
hcrawfdev wants to merge 4 commits intobloominstituteoftechnology:masterfrom
hcrawfdev:master
Open

WIP (Harrison Crawford)#232
hcrawfdev wants to merge 4 commits intobloominstituteoftechnology:masterfrom
hcrawfdev:master

Conversation

@hcrawfdev
Copy link
Copy Markdown

callbacks completed sans stretch goal

if (callCout === n){
return null;
}
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Need a ; semicolon after every return statement.

let newArr = [];
for (let i = 0; i < elements.length; i++) {
if (Array.isArray(elements[i])) {
newArr = newArr.concat(flatten(elements[i]));
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 stuff!

// `startingValue` should be the first argument passed to `cb` and the array element should be the second argument.
// `startingValue` is the starting value. If `startingValue` is undefined then make `elements[0]` the initial value.
let memo = elements.shift();
if (startingValue !== undefined) memo = cb(memo, startingValue);
Copy link
Copy Markdown

@frankfaustino frankfaustino Feb 23, 2018

Choose a reason for hiding this comment

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

Instead of if (startingValue !== undefined), you could simply do if (startingValue).

Also, since reduce() method doesn't mutate the original array, try to figure out a solution that doesn't mutate the elements array. Here you're using shift() which does mutate elements

// Return the new array.
const newArray = [];
for (let i = 0; i < elements.length; i++) {
return newArray.push(cb(elements[i], i));
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 shouldn't return inside a for loop since it will terminate the loop after the first iteration.

@frankfaustino
Copy link
Copy Markdown

Hey Harrison! Good work so far. Looks like you've got a good handle on Objects and Arrays. I'll cover the exercises you didn't complete during our group review session today.

Keep up the good work! Please close this PR after reviewing feedback.

// Do not mutate the original array.
const newArray = array.slice();
for (let i = 0; i < newArray.length - 1; i++) {
if (newArray[i] === newArray[i++]) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your solution here doesn't actually remove the duplicate Array items. Also, did you work with Jessica on this problem? Your code is identical to hers.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

hey Frank! just figured out how to open this page on github and not through email. Yes, we worked on many problems in this assignment with each other in our partner group

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