I have a unique collection of arrays with varying lengths. For example, in my test scenario, I initialized my vidArray
with 4 arrays (having lengths of 16, 38, 49, and 49 respectively). My goal is to create a newArray
that combines the elements from each array in sequence.
This is my approach:
// populate newArray
var newArray = []
for(let i=0; i < vidArray.length; i++){
let currentArray = vidArray[i]
for(let j=0; j < currentArray.length; j++){
newArray.push(currentArray[j])
}
}
console.log("newArray: "+newArray)
However, the output appears incorrect as it seems to mix elements from different arrays inconsistently.