I have an object that is like this:
let obj = {
links: {},
data: [
{
type: "type",
id: "id",
attributes: {
name: "some-name",
},
},
{
type: "type",
id: "id",
attributes: {
name: "some-other-name",
},
},
],
};
let array = obj.data;
So I have an object with key and value that is another object, that is in another object that is in array, and that array is in object.
I want to know how to find the exact value, for example I want to find value “some-other-name”, how can I do that. I tried with
for (let i in array)
if(array[i].attributes.name === "some-other-name") {
return array[i];
but it seems like it’s not working.
Can someone help?