I got the following solution to pass all tests except “All elements from the first array should be added to the second array in their original order.” Any idea why?
function frankenSplice(arr1, arr2, n) {
let resultArr = []
for (let i = 0; i < arr2.length; i++){
if (i == n) {
resultArr.push(...arr1)
}
resultArr.push(arr2[i]);
}
return resultArr;
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);