Created
January 1, 2017 21:08
-
-
Save mannuelf/f9fdd41bbe0f1b31ac708beeec981111 to your computer and use it in GitHub Desktop.
find helper
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 users = [ | |
{ name: 'Alan', surname: 'Shearer' }, | |
{ name: 'Micheal', surname: 'Owen' }, | |
{ name: 'Peter', surname: 'Beardsley' } | |
]; | |
var user; | |
/* | |
for (var i = 0; i < users.length; i++) { | |
if (users[i].name === 'Micheal') { | |
user = users[i]; | |
break; | |
} | |
} | |
*/ | |
users.find(function(user) { | |
return user.name === 'Alan' | |
}); | |
user; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment