Create Functions Using Array Filter Method#13
Open
ASPhillips8 wants to merge 1 commit intolearn-co-curriculum:masterfrom
Open
Create Functions Using Array Filter Method#13ASPhillips8 wants to merge 1 commit intolearn-co-curriculum:masterfrom
ASPhillips8 wants to merge 1 commit intolearn-co-curriculum:masterfrom
Conversation
stephenmckeon
approved these changes
May 10, 2024
Comment on lines
+23
to
+48
| // goes into arrayDriver and pulls name value that matches soughtname | ||
|
|
||
| // to get name key use dot notation on object | ||
| // pull from array object that match sought name | ||
| // source = driver object | ||
|
|
||
| const soughtName = "Annette" | ||
| const arrayDriver = [ | ||
| { | ||
| name: 'Bobby', | ||
| hometown: 'Pittsburgh' }, | ||
| { | ||
| name: 'Sammy', | ||
| hometown: 'New York' } , | ||
| { | ||
| name: 'Sally', | ||
| hometown: 'Cleveland' }, | ||
| { | ||
| name: 'Annette', | ||
| hometown: 'Los Angeles' }, | ||
| { | ||
| name: 'Bobby', | ||
| hometown: 'Tampa Bay' } | ||
| ]; | ||
|
|
||
| matchName(arrayDriver, soughtName) |
There was a problem hiding this comment.
Please clean this up next time:
Suggested change
| // goes into arrayDriver and pulls name value that matches soughtname | |
| // to get name key use dot notation on object | |
| // pull from array object that match sought name | |
| // source = driver object | |
| const soughtName = "Annette" | |
| const arrayDriver = [ | |
| { | |
| name: 'Bobby', | |
| hometown: 'Pittsburgh' }, | |
| { | |
| name: 'Sammy', | |
| hometown: 'New York' } , | |
| { | |
| name: 'Sally', | |
| hometown: 'Cleveland' }, | |
| { | |
| name: 'Annette', | |
| hometown: 'Los Angeles' }, | |
| { | |
| name: 'Bobby', | |
| hometown: 'Tampa Bay' } | |
| ]; | |
| matchName(arrayDriver, soughtName) |
Comment on lines
+15
to
+21
| function matchName(arrayDriver, soughtName) { | ||
| console.log("test") | ||
| return arrayDriver.filter((possibleDriver) => { | ||
| return possibleDriver.name === soughtName | ||
| console.log(matchName(arrayDriver, soughtName)) | ||
| }) | ||
| } |
There was a problem hiding this comment.
Suggested change
| function matchName(arrayDriver, soughtName) { | |
| console.log("test") | |
| return arrayDriver.filter((possibleDriver) => { | |
| return possibleDriver.name === soughtName | |
| console.log(matchName(arrayDriver, soughtName)) | |
| }) | |
| } | |
| function matchName(arrayDriver, soughtName) { | |
| return arrayDriver.filter((possibleDriver) => { | |
| return possibleDriver.name === soughtName | |
| }) | |
| } |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Create function to return list of matching drivers using filter method. Create function to return list of drivers with matching letters using array filter method. Create function to return name element using array filter method.