Created
January 13, 2019 20:54
-
-
Save apolopena/a94c09dfe76004bda2e8824f6b70d32b to your computer and use it in GitHub Desktop.
JavaScript: Array.prototype.find() wrapper example
This file contains 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
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