Skip to content

Create Functions Using Array Filter Method#13

Open
ASPhillips8 wants to merge 1 commit intolearn-co-curriculum:masterfrom
ASPhillips8:array_filter_asp
Open

Create Functions Using Array Filter Method#13
ASPhillips8 wants to merge 1 commit intolearn-co-curriculum:masterfrom
ASPhillips8:array_filter_asp

Conversation

@ASPhillips8
Copy link

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.

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)

Choose a reason for hiding this comment

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

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))
})
}

Choose a reason for hiding this comment

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

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
})
}

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