reduce array of arrays into on array in collated order reduce array of arrays into on array in collated order arrays arrays

reduce array of arrays into on array in collated order


Maybe just a simple for... i loop that checks each array for an item in position i

var input = [["one","two","three"],["uno","dos"],["1","2","3","4"],["1st","2nd","3rd"]]var output = []var maxLen = Math.max(...input.map(arr => arr.length));for (i=0; i < maxLen; i++) {  input.forEach(arr => { if (arr[i] !== undefined) output.push(arr[i]) })}console.log(output)