I'm getting the desired output, so why is the challenge not succeeding?

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:

Have you considered a case in which second array is empty?

oh yeah, that wrecks everything… but it’s not related to the error message I’m getting.

That depends, are elements from first array added to the second in such case?

hey, you’re right. I added

if (arr2.length == 0) {
return arr1;
}

and now it’s working. Thanks!

I see the actual solutions involving the slice function appear more elegant and simpler.