I am working with structured data that looks like the example below:
const arr = [{
id: 0,
name: 'Biomes',
icon: 'mdi-image-filter-hdr',
isParent: true,
children: [{
id: 1,
name: 'Redwood forest',
icon: 'mdi-image-filter-hdr'
}]
},{
id: 2,
name: 'Trees',
icon: 'mdi-pine-tree',
children: [{
id: 8,
name: 'Redwood',
icon: 'mdi-pine-tree'
}]
}];
The main array consists of objects, each object having a field children
which can also be an array of objects. If I have the value of id
, how can I locate the object (especially the object name) based on that id?