js怎么得到二维数组中对比出来的最大值?

让每列数据进行对比,得出每列数据的最大值,反回新的数组。

如下数据:

[
 [21,8.4,8.4,8.4,8.8,12.11,17.6,24.12,17.6,23.1], 
 [25.3,8.4,8.4,8.4,8.4,17.6,8.4,29.42,17.6,45.8],
 [21,8.4,8.4,8.4,11,17.6,8.4,29.42,13.21,35.2]
]

比如现在第一列,最大值就是[25.3],第二例是[25.3, 8.4]... 以此类推

解决了:

 // 对比每列最大值
      let aotuWidth = []
      dataJson.map((row, index) => {
        let maxWidth = [];
        row.map((value, i) => {
          if (index === 0) {
            maxWidth.push({ wch: value });
          } else {
            maxWidth.push({ wch: Math.max(value, aotuWidth[i].wch) })
          }
        })
        // console.log("最大值:", maxWidth);
        aotuWidth = maxWidth;
      });
      console.log("每列最大宽度:", aotuWidth);