so I can't solve this issue. I have the following arrays:
var array1 = [
USA,
Georgia,
Atlanta
]
var array2 = [
USA,
New York
]
This is what I want:
{
"counties": [
{
"name": "USA",
"id": "1",
"children": [
{
"name": "Georgia",
"id": "1.1",
"parentId": "1",
"children": [
{
"name": "Atlanta",
"id": "1.1.1",
"parentId": "1.1"
}
]
},
{
"name": "New York",
"id": "1.2",
"parentId": "1"
}
]
}
]
}
The trick is to not to have any duplications, if there is any duplications on the same level, they should be merged into one and have both's children under. Like USA in the example.