Last active
December 25, 2018 23:38
-
-
Save alexTitakoff/9f2cfeacc589e59d02040dfe331824ac to your computer and use it in GitHub Desktop.
== нахождение объекта в массиве по атрибуту
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
function findWithAttr(array, attr, value) { | |
for(var i = 0; i < array.length; i += 1) { | |
if(array[i][attr] === value) { | |
return i; | |
} | |
} | |
return -1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment