WIP (Harrison Crawford)#232
WIP (Harrison Crawford)#232hcrawfdev wants to merge 4 commits intobloominstituteoftechnology:masterfrom
Conversation
| if (callCout === n){ | ||
| return null; | ||
| } | ||
| } |
There was a problem hiding this comment.
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])); |
| // `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); |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
You shouldn't return inside a for loop since it will terminate the loop after the first iteration.
|
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++]) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
callbacks completed sans stretch goal