Skip to content

Instantly share code, notes, and snippets.

@apolopena
Created January 13, 2019 20:54
Show Gist options
  • Save apolopena/a94c09dfe76004bda2e8824f6b70d32b to your computer and use it in GitHub Desktop.
Save apolopena/a94c09dfe76004bda2e8824f6b70d32b to your computer and use it in GitHub Desktop.
JavaScript: Array.prototype.find() wrapper example
var ladders= [{height: '20 feet'}, {height: '10 feet'},{height: '100 feet'}];
function findWhere(array, criteria) {
return array.find(function(item){
return item.height === criteria.height;
});
}
var twentyFootLadder = findWhere(ladders, {height: '20 feet'});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment