Using Slice and Splice Works, Cannot Pass Test

Tell us what’s happening:
My code below works for the different edge cases provided. Was wondering if there is an exact syntax that FCC wants to pass this lesson.

Your code so far


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

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

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/slice-and-splice

this one prints [ 'head', 'shoulders', [ 'claw', 'tentacle' ], 'knees', 'toes' ]
it is failint two things: you have changed arr2, when instead it should stay invaried, and you have added the whole array insead of the elements of the array

I tested on the Console and I see what you’re saying. I now have the following …

function frankenSplice(arr1, arr2, n) {
  // It's alive. It's alive!
  let firstArr = arr1.slice()
  let copy = arr2;
  for(let i=firstArr.length-1;i>=0;i--){
    copy.splice(n,0,firstArr[i])
  }
  return copy;
}
frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2);

This satisfies all edge cases but it cannot satisfy the checkpoint: The second array should remain the same after the function runs. Any insight?

why are you doing this? you are not changing this one, so it is not necessary to create a copy of an array you are not changing

this though is not a copy, this is just a change of reference, you are still modifying arr2

Not sure as to why I sliced the first array. Can’t recall my thought pattern. Nevertheless, I did let copy = arr2.slice() and removed let firstArr = arr1.slice().

Thank you!