This repository was archived by the owner on Aug 31, 2019. It is now read-only.
Project W1(B) - Completed#38
Closed
Track7Dev wants to merge 8 commits into
Closed
Conversation
Array Section Completed. Extra Credit : In-Progress.
Array Section & Extra Credit Completed.
-Arrays: Completed -Class: Completed
-Arrays: Completed -Class: Completed -Closure: Completed
-Arrays: Completed -Class: Completed -Closure: Completed -ES6: Completed
-Arrays: Completed -Class: Completed -Closure: Completed -ES6: Completed -Objects: Completed
-Arrays: Completed -Class: Completed -Closure: Completed -ES6: Completed -Objects: Completed -'This': Completed
-Arrays: Completed -Class: Completed -Closure: Completed -ES6: Completed -Objects: Completed -'This': Completed -Recursion: Completed
seanchen1991
left a comment
Contributor
There was a problem hiding this comment.
Nice job on this assignment. I left a few comments on your syntax, but overall it's pretty good.
| // Iterates over a list of elements, yielding each in turn to the `cb` function. | ||
| // This only needs to work with arrays. | ||
| // based off http://underscorejs.org/#each | ||
| for (let i = 0; i < elements.length; i++) { cb(elements[i], i); } |
Contributor
There was a problem hiding this comment.
For readability's sake, I would definitely move cb(elements[i], i); to its own line.
| // Produces a new array of values by mapping each value in list through a transformation function (iteratee). | ||
| // Return the new array. | ||
| const newArr = []; | ||
| for (let i = 0; i < elements.length; i++) { newArr.push(cb(elements[i])); } |
| // 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. | ||
| // `memo` is the starting value. If `memo` is undefined then make `elements[0]` the initial value | ||
| if (memo === undefined) memo = elements[0]; |
Contributor
There was a problem hiding this comment.
Here you can just do if (!memo)
| for (let i = 0; i < elements.length; i++) { | ||
| if (cb(elements[i])) return elements[i]; | ||
| } | ||
| return undefined; |
Contributor
There was a problem hiding this comment.
Just to save yourselves a few keystrokes, you can just return; here, which is the same as doing return undefined;.
| this.password = options.password; | ||
| } | ||
| comparePasswords(pass) { | ||
| if (pass === this.password) return true; |
Contributor
There was a problem hiding this comment.
Here you can just do return pass === this.password;
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
-Arrays: Completed
-Class: Completed
-Closure: Completed
-ES6: Completed
-Objects: Completed
-'This': Completed
-Recursion: Completed