Tell us what’s happening:
i have passed every test on this lesson except for this one: “All elements from the first array should be added to the second array in their original order.”
it seems to me that my code is accomplishing that. i’m wondering what i did wrong.
Your code so far
function frankenSplice(arr1, arr2, n) {
let arr3 = [];
for (let i = 0; i < arr2.length; i++) {
if (i == n) {
for (let j = 0; j < arr1.length; j++) {
arr3.push(arr1[j]);
}
}
arr3.push(arr2[i]);
}
return arr3;
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36.
You are taking items from both arrays and adding the to a third array this is why you are getting the error because you should be adding the arr1 items to the arr2, and not use a third array,.
Also this is a splice and slice test so you should be using them instead of loops, you will have to use slice atleast so you pass the The first array should remain the same after the function runs. test.