I have an array as such:
data = [
{id:343, article:'yes', image:'ok'},
{id:35, article:'ko', image:'twe'},
{id:212, article:'ere', image:'efe'},
{id:90, article:'fefe', image:'fe'}
]
I am trying to loop through the array object, then grab id
, article
, and image
data where id is equal to a certain number. So for example I want to grab id
, article
, and image
when id is equal to 90
.
I am able to discern the array and if the id exists as such:
data.forEach(function(key,value){
if (key['id'] === 343) {
//how to grab rest of this object?
}
})
but from there I don't know how to grab the rest of the object data.
How would I go about this? Any help would be greatly appreciated.