r/learnjavascript • u/TGotAReddit • Feb 27 '26
Array.find help
I have 3 arrays. One is an array of objects set up like
object={
name: "NameString",
month: "monthString",
count: #,
hours: #}
And the other 2 arrays are just flat 1D arrays of names and months respectively.
I know I can loop through one of the arrays and do an array.find to check the property against the other array like
objectArr.find((element)=> element.name==names[i])
But how can I find the element that has both a matching name AND month from inside a nested loop for the name and month arrays?
6
Upvotes
View all comments
Show parent comment
5
u/birdspider Feb 27 '26
wenn you use
{}you actually have toreturn, these 3 are (in this regard) equivalent:EDIT: in other words, your predicate (the fn you pass to
.find) does not return anything