I have an array like so:
const array = [
{
'12345': [
{
name: 'item one',
numbers: ['12345', '77484'],
},
{
name: 'item two',
numbers: ['12345', '65456'],
},
{
name: 'item three',
numbers: ['12345', '33920'],
},
{
name: 'item four',
numbers: ['12345', '99393'],
},
],
},
{
'67890': [
{
name: 'item one b',
numbers: ['67890', '33232'],
},
{
name: 'item two b',
numbers: ['67890', '33456'],
},
{
name: 'item three b',
numbers: ['67890', '77665'],
},
{
name: 'item four b',
numbers: ['67890', '11234'],
},
],
},
]
console.log(array);
If I am given a name as a dynamic variable, for example, 'item three b', how can find that name inside the array of objects of the array of objects to delete it?
I'm stumped when trying to get into the nested array.
Thanks!
mapoffind, you could get the object. What are you then wanting to do with it? Delete it? That makes it a bit different.item three b, how do I find it in the nested array and delete it. Thanks. I've triedfind()but I cannot get into the nested array withfind(). I can loop through the first level of objects, but I am stumped when getting into the nested array.