How to nest arrays?

I want to put array elements into another array nested like below. How to do that? Thank you.

let myArr = ["A", "B", "C", "D", "E"];

let func = (myArr) => {

//some magic here

return result; //result should be  [["A"], ["B"], ["C"], ["D"], ["E"]]

}

in many ways…

  • you could push the values wrapped in an array to an other array,
  • you could use map()

what have you tried youraelf?

1 Like

let result = myArr.map(x => [x]);

it worked! thanks