I'm getting an array from the backend that has an abritrary number of nested arrays. Each array element is a company and may or may not have a Children property which is again an array of companies that each may or may not have child companies. For example:
[
{
Name:"Company X",
Children:[
{
Name:"Company XY"
},
{
Name:"Company XZ",
Children:[
{
Name: "Company XZY" // third level of nested arrays, can be an abritrary number of levels
}
]
}
]
},
{
Name:"Company Y",
Children:[
{
Name:"Company YZ"
}
]
}
]
I have to add a "Label" property to each company object. The property is equal to the "Name" property.
How can I do this in JavaScript?