I have just started learning JavaScript, I am wondering what is the easiest and right way to find and delete specific element by id in the array of nested object.
I want to delete item from this data by specific ID.
my code
const initialData = [
{
title: 'lover',
data: [ { uId: 392928377430992 }, { uId: 39292837743099 } ],
},
{
title: 'lover2',
data: [ { uId: 392928377431244 }, { uId: 392928377413213 } ]
},
];
const newArray = initialData.map((el) => { return el.data });
const findInNewArray = newArray.filter((el) => { return el.uId != 392928377413213 });
console.log(findInNewArray);