I have a array like this :
const data = [
{
key: 1010,
children: [
{ key: 10101, children: [] },
{
key: 10102,
children: [
{
key: 1010101,
checked: false,
},
{
key: 1010102,
checked: false,
},
],
},
],
},
{
key: 2020,
children: [
{
key: 20201,
children: [
{
key: 202020,
checked: false,
},
{
key: 202021,
checked: false,
},
],
},
],
},
];
And I want to get a output like this :
const output = {
idsGrid: [
{
gridId: 10101,
isTable: false,
},
{
gridId: 10102,
isTable: false,
},
{
gridId: 1010101,
isTable: true,
},
{
gridId: 1010102,
isTable: true,
},
{
gridId: 20201,
isTable: false,
},
{
gridId: 202020,
isTable: true,
},
{
gridId: 202021,
isTable: true,
},
],
};
Actually, I want to map into my seconds level's arrays and extract all object and push them into only One array, with IsTable property (WHEN checked is false ==> IsTable is TRUE)
I'm trying using recursive method but it's not working right now..
This is what I'm trying :
console.log('data ==>',data)
let a = []
const v = data.map(e => {
return e.children.map(child => {
return a.push({key : child.key,isTable : true})
})
} )
