If I have this object:
DropIds = [
{
"studentId": 5,
"dropboxItems": [
{
"dropBoxId": 230,
}
]
},
{
"studentId": 4,
"dropboxItems": [
{
"dropBoxId": 585,
},
{
"dropBoxId": 586,
}
]
}
]
And I try to run this code:
var result = $.grep(DropIds, function(e){
return e.dropboxItems[0].dropBoxId == 585;
});
it will return a result, however if I change it from 585 to 586 the result is empty.
http://jsfiddle.net/tdb70f50/1/
So it looks like my code will only check the first object in the array.
How can I grab the object when there is more than one dropBoxId?
Thanks!
dropboxItemsrather than just look at the first item.