Hi everyone I need to get advice on how to realize such a function for searching and adding property if the children's scope has the same ids as the parent scope and add isDisable key.
The data which I got and I need to transform it with new property isDisable
const data = [
{
id: "MT1",
children: []
},
{
id: "MT2",
children: []
},
{
id: "MT4",
children: []
},
{
id: "1234",
children: [
{
id: "MT1",
children: []
},
{
id: "MT65",
children: []
},
]
},
{
id: "537465",
children: [{
id: "MT1",
children: []
},
{
id: "MT2",
children: [
{
id: "MT1",
children: []
},
{
id: "MT12",
children: []
}
]
},
]
}
]
This is some function for searching and adding a property to an item and result.
const someSearchFunction = (data) => {}
console.log(someSearchFunction(data))
const data = [
{
id: "MT1",
children: [],
isDisable: false
},
{
id: "MT2",
children: [],
isDisable: false
},
{
id: "MT4",
children: [],
isDisable: false
},
{
id: "MT12",
children: [],
isDisable: false
},
{
id: "1234",
children: [
{
id: "MT1",
children: [],
isDisable: true
},
{
id: "MT65",
children: [],
isDisable: false
},
]
},
{
id: "537465",
children: [
{
id: "MT1",
children: [],
isDisable: true
},
{
id: "42354322",
children: [
{
id: "MT1",
children: [],
isDisable: true
},
{
id: "MT12",
children: []
isDisable: false
}
]
},
]
}
]
Thanks!