+ 16
Transformation of a flat array into multidimensional
I have such array: let mdarr = [ true, -Infinity, NaN, undefined, "4rontender", {"lol": [ 0, 1, 2 ] } ]; something like this in the output: -> [ [ [ true, [ -Infinity, NaN ] ] ], [ undefined, ["4rontender", [ {"kek": [ 2, 1, 0 ] } ] ] ] ]; // hint: mdarr = [ Array(1), Array(2) ] Is it realistic to do this? And what is the fastest and most optimal solution? Thanks:-)
3 Answers
+ 10
Please, pay attention to the object of the resulting array:
it was so: {"lol": [ 0, 1, 2 ] }, but it became so: {"kek": [ 2, 1, 0 ] }
+ 9
you can reduce dimensions. but of course I need universal solution and with different data types, and most optimalđ
+ 5
Always possible but I still don't know the pattern đ”