I have an array like this:
initialArray = ["a", "b", "c". "d.e", "d.e.f", "d.e.g", "d.h.i", "d.h.j"]
But I want this array like this or the closest as possible:
finalArray: [
{ "a": [] },
{ "b": [] },
{ "c": [] },
{ "d": [
{ "e": [ "f", "g" ] },
{ "h": [ "i", "j" ] }
] },
]
The values of initialArray are randomly assigned. The values and the length of the comma separated strings can be changed (there can be more or less letters in those strings), so that I need a general idea to build that finalArray. I'd really be appreciated if someone can help me. Thank you so much.
initialArraytofinalArray?