The problem of vertical arrangement of two-dimensional arrays?

I want to put const arr = [

]
[10, 22, 33, 14, 25, 56],
[11, 12, 31, 24, 15, 26],

]
becomes const result = [

[10, 11],
[22, 12],
[33, 31],
[14, 24],
[25, 15],
[56, 26]

]

what should I do

Mar.03,2021

first of all, you should try it by yourself. Even if you don't write well, there is a lot of recursive for loops, and even if you can't write it, it's better than not trying at all. At least there is an idea

.
var data = [[10, 22, 33], [11, 12, 31, 24, 15, 26], [10, 22, 33]]
var res = Array(Math.max(...data.map(arr => arr.length)))
  .fill()
  .map((val, index) => [data.map(v => v[index])])
console.log(res)

the idea of this question:

  1. The length of res is determined by the longest in data , so Math.max (.data.map (arr = > arr.length))
  2. For res , add the items in data in turn, so (val, index) = > [data.map (v = > v [index])]
  3. Fill the array with fill () before and after
  4. , so that the map method of ES5 can be applied

tie first, and then group it in pairs.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c2ab-2c2fd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c2ab-2c2fd.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?