[Solved] How to Invert an array in javascript


Assuming you have string and number in pairs. You can try following logic

var abc = ['S', 'L', 'M', 20, 30, 60];

var updated = [];
var mid = abc.length/2;

for (var i=0; i< mid;i++) {
   updated.push(abc[i]);
   updated.push(abc[mid+i]);
}

console.log(updated);

0

solved How to Invert an array in javascript