Having trouble with TypeScript, specifically working with arrays and filtering out leaf nodes. I want to print only the leaf nodes in the array, resulting in ['002', '004', '007']. Can someone please assist me? Excited to learn! Thank you in advance!
Here is the initial array structure:
[
{
Name: "A",
HasChildren: true,
Children: [
{
Name: "002",
HasChildren: false,
Children: []
},
{
Name: "004",
HasChildren: false,
Children: []
}
]
},
{
Name: "007",
HasChildren: false,
Children: []
}
]
If the array is:
[ {
Name: "007",
HasChildren: false,
Children: []
}
]
The resulting array should be: ['007']