Slice and Splice trying to figure out what's wrong with my code

Tell us what’s happening:
Hey I’m trying to figure out what’s wrong with my code here. I’ve tried every given input, and using console.log() I can see the function is returning the correct output, but the app won’t let me pass the challenge.

I saw the solution and they use a for loop to iterate through arr1 when copying it to the arr2. Maybe there’s the catch?

Thank you all for your help :slight_smile:

Your code so far


function frankenSplice(arr1, arr2, n) {
  // It's alive. It's alive!
let arr3 = arr2.slice();
    arr3.splice(n,0,arr1.slice());
    console.log(arr3);
    return arr3;
}

frankenSplice([1, 2, 3], [4, 5], 1);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0.

Link to the challenge:
They won’t let me post using links, but here’s the description of the challenge:

## Basic Algorithm Scripting: Slice and Splice

You are given two arrays and an index.

Use the array methods slice and splice to copy each element of the first array into the second array, in order.

Begin inserting elements at index n of the second array.

Return the resulting array. The input arrays should remain the same after the function runs.

Remember to use [Read-Search-Ask] if you get stuck. Write your own code.

If I remember this challenge correctly, it should be returning a 1-dimensional array. You are returning a multi-dimensional array.

Oh… Got it. Thank you!

Glad I could help. Happy coding!