-
Notifications
You must be signed in to change notification settings - Fork 264
JavaScript I without stretch questions #298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,22 +5,26 @@ const keys = (obj) => { | |
| // Retrieve all the names of the object's properties. | ||
| // Return the keys as strings in an array. | ||
| // Based on http://underscorejs.org/#keys | ||
| return Object.keys(obj); | ||
| }; | ||
|
|
||
| const values = (obj) => { | ||
| // Return all of the values of the object's own properties. | ||
| // Ignore functions | ||
| // http://underscorejs.org/#values | ||
| return Object.values(obj).map(key => obj[key]); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| }; | ||
|
|
||
| const mapObject = (obj, cb) => { | ||
| // Like map for arrays, but for objects. Transform the value of each property in turn. | ||
| // http://underscorejs.org/#mapObject | ||
| return Object.values(obj).map(key => cb(obj[key])); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a few things wrong with this. |
||
| }; | ||
|
|
||
| const pairs = (obj) => { | ||
| // Convert an object into a list of [key, value] pairs. | ||
| // http://underscorejs.org/#pairs | ||
| return Object.keys(obj).map(key => [key, obj[key]]); | ||
| }; | ||
|
|
||
| /* STRETCH PROBLEMS */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exactly the solution code from the solution branch... In the future I'd like to see where you got with your own code.