[Solved] How to modify multidimensional array? [duplicate]


We can do it via Array.map()

const data = [[11,12,13,14],[21,22,23,24],[31,32,33,34],[41],[43],[51]]

let result = data.map(d => {
   if(d.length < 2){
     return d[0]
   }
   return d.at(0) +' -' + d.at(-1)
})
console.log(result)

solved How to modify multidimensional array? [duplicate]