Skip to content

Created Functions to Filter Data#12

Open
cmhorsey wants to merge 1 commit intolearn-co-curriculum:masterfrom
cmhorsey:test_branch
Open

Created Functions to Filter Data#12
cmhorsey wants to merge 1 commit intolearn-co-curriculum:masterfrom
cmhorsey:test_branch

Conversation

@cmhorsey
Copy link

@cmhorsey cmhorsey commented May 9, 2024

Used array.filter functions to manipulate objects and arrays

Comment on lines +10 to +14
function fuzzyMatch(array, name) {
return array.filter(function(driver) {
return driver.substring(0, 1) === name.substring(0, 1);
});
}
Copy link

@stephenmckeon stephenmckeon May 10, 2024

Choose a reason for hiding this comment

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

So this works, and passes the test, but not for all examples (if the name provided was "Ste", this would provide a false positive for "Stove" since it's only looking at the first 2 letters of either). Take a peak at the startsWith function. You don't need to make changes, but if you have extra time, play around with it. Thanks!

Suggested change
function fuzzyMatch(array, name) {
return array.filter(function(driver) {
return driver.substring(0, 1) === name.substring(0, 1);
});
}
function fuzzyMatch(array, name) {
return array.filter(function(driver) {
return driver.substring(0, 1) === name.substring(0, 1);
});
}

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