Why needed .slice to remain unharmed?

What is wrong with my code?

It says:
The second array should remain the same after the function runs.

Why should I add .slice() at the end of the second line?

  **Your code so far**

function frankenSplice(arr1, arr2, n) {
  let arr3 = arr2;

  arr3.splice(n,0, ...arr1)

  return arr3;

console.log(frankenSplice([1, 2, 3], [4, 5, 6], 1));

  **Your browser information:**

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

Challenge: Slice and Splice

Link to the challenge:

this is not a copy of arr2, here you are creating a new reference to arr2

you can find the tool here

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