[Solved] combining two arrays in specific format


Should work with arrays of any length.

let arr = [{'test' : 1}, {'test1' : 2}, {'test2': 3}, {'test3': 4}];
let arr1 = [{'testdo': 5}, {'testdo1': 6}, {'testdo2': 7}, {'testdo3': 8}];

let arr3 = [];
let max = Math.max(arr.length, arr1.length);

for (let i=0; i < max; i++) {
  if (arr.length > i) {
    arr3.push(arr[i]);
  }
  if (arr1.length > i) {
    arr3.push(arr1[i]);
  }
}

console.log(arr3);

solved combining two arrays in specific format