assuming an N-th dimensional array, eg.
const array = [
"1",
["2","2"],
[["3","3"],["3","3"]],
[
[
[["4","4"],"3"],
[["4","4"],"3"]
],
],
[["3","3"],["3","3"]],
["2","2"],
"1"
];
I can only find methods to flatten arrays from shallow-end of the index up, but I need to flatten/reduce or otherwise handle only the deepest (or any arbitrary) index level.
When running the deepest level I am looking for an array output something along the lines of
array = [
"1",
["2","2"],
[["3","3"],["3","3"]],
[
[
["4,4","3"],
["4,4","3"]
],
],
[["3","3"],["3","3"]],
["2","2"],
"1"
];
I cannot find a solution that isn't garbage... (over-complicated/incredibly messy) Any help would be appreciated