Skip to content

Instantly share code, notes, and snippets.

@josephdicdican
Last active January 24, 2017 09:54
Show Gist options
  • Save josephdicdican/aedb69ccab9bd6641ecacc5328c774bf to your computer and use it in GitHub Desktop.
Save josephdicdican/aedb69ccab9bd6641ecacc5328c774bf to your computer and use it in GitHub Desktop.
JS array filter
var dogs = ['Shuggy', 'Bobo', 'Whity', 'Moby', 'Molly', 'Charlie', 'Bolly', 'Chappie', 'Bella'];
var b_dogs = dogs.filter(function(dog) {
return startsWithB(dog);
});
function startsWithB(dog) {
return dog.startsWith("B");
}
console.log(b_dogs);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment