Answer the question
In order to leave comments, you need to log in
How to pass data from children to parent in a tree object?
Good afternoon, there is such an object in the array
[
{
"id": 1,
"parentid": null,
"count": "0",
"children": [
{
"id": 2,
"parentid": 1,
"count": "89",
"children": [
{
"id": 3,
"parentid": 2,
"count": "19",
"children": [
{
"id": 5,
"parentid": 3,
"count": "205"
},
{
"id": 4,
"parentid": 3,
"count": "8"
}
]
}
]
}
]
}
]
Answer the question
In order to leave comments, you need to log in
Recursively traverse the entire tree in depth and calculate for each element the data on its descendants.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question