Any suggestions on simplifying and enhancing the code provided below?
The current code works as intended when myarr.length === 2
:
[...myarr[0].arrk.map(myfunc), ...myarr[1].arrk.map(myfunc), ...myarr[2].arrk.map(myfunc)]
How can we adjust the above code to accommodate an array length of any size, rather than just 2? It should work for all lengths.
P.S. I feel like the solution
myarr.map(a => a.arrk.map(myfunc))
is almost there, but not quite: it returns [Array(1), Array(2)]
, instead of the elements.
Thank you!