Unable to pass "All elements from the first array should be added to the second array in their original order"

Tell us what’s happening: Passed all tests except this one. I do not know what I have to do to pass it. arr1 is already copied to the new array in the same order using ES6 spread. If someone could advise me, that would me nice, thanks.

  **Your code so far**

function frankenSplice(arr1, arr2, n) {
if (n >= arr2.length)
  return;
let newArr = [...arr2];
newArr.splice(n,0,...arr1);
return newArr;
}

console.log(frankenSplice([1, 2, 3], [4, 5], 1));
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36.

Challenge: Slice and Splice

Link to the challenge:

The issue is with your if statement. The test doesn’t require that you check that condition. You can actually either remove the if statement entirely, or you can delete the “=” from it.

I can only guess the reason for it is if the index is equal to the array length, you could still insert the first array at the end of the second array and return that. That’s my guess at least. :man_shrugging:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.