Splice and slice challenge

Hey, I have a problem with this challenge:

"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."

Here is my code:

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

console.log(frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2));

It seems to work just fine but it doesn’t seem to pass the tests for some reason.

Can anyone help?

Ah, I guess I see the problem. The whole array is inserted, instead of just its elements… Sorry this is my first post and asking for help for the very first time :slight_smile:
If anyone could just confirm, this would be great :smile:

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums

You’ve correctly identified your problem. Here you can see that the solution above creates a multi-dimensional array instead of a flat array: