Tell us what’s happening:
I think my code achieves the stated goals, but I keep getting the message “All elements from the first array should be added to the second array in their original order.”
I’ve run it through different inputs for arr1 and arr2, it seems like it always keeps arr1 and arr2 in original order. I’m not sure what’s going on here.
**Your code so far**
function frankenSplice(arr1, arr2, n) {
let insertedArray = [];
for (let i = 0; i < arr2.length; i++) {
if (i == n) {
insertedArray.push(...arr1); //when i = n, jump to pushing arr1, then arr2[i]
insertedArray.push(arr2[i]);
}
else {
insertedArray.push(arr2[i]); //else keep pushing arr2
}
}
return insertedArray;
}
console.log(frankenSplice([1, 2], ['a', 'b',3,5,6], 3));
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36.
Challenge: Slice and Splice
Link to the challenge: