When given two arrays and indices, the task is to combine a portion of the first array with a reversed portion of the second array.
For instance:
// Provided Input
arr1 = [1,2,3,4,5,6,7,8,9];
arr2 = [10,11,12,13,14,15];
ind1 = 6;
ind2 = 3;
// Expected Output
arr = [1,2,3,4,5,6,12,11,10];
This is my current implementation:
function Concat(arr1,arr2,ind1,ind2) {
let arr = [];
for (let n = 0; n < ind1; n++)
arr.push(arr1[n]);
for (let n = ind2; n > 0; n--)
arr.push(arr2[n-1]);
return arr;
}
I am open to suggestions on how this can be improved in terms of efficiency or simplicity. Any ideas?