Slice and Splice using spread

Tell us what’s happening:
I was testing this in code play and it seems it is giving me the right results but fcc does not allow it. I want to understand why this will not work in real code scenario.

Your code so far

function frankenSplice(arr1, arr2, n) {
  // It's alive. It's alive!
  let Arry = arr2.slice();
    Arry.splice(n, 0, [...arr1]);
    return Arry;
frankenSplice([1, 2, 3], [4, 5, 6], 1);

Thanks would truly appreciate any input on this.

Your browser information:

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

Link to the challenge:

This will insert a copy of the arr1 array into Arry, because you’re using the spread operator in a new array, not in the argument list itself. That results to


instead of


It just so happens that they both have the same string representation:


Arry.splice(n, 0, ...arr1); so this will work as you’re only copying the elements inside the array and not the array itself.

@kevcomedia got it so by using […arr] , I inserted/nested another array inside my array…

Ooh my! this is my missing link!

Thanks. Truly appreciate it!
I have been playing around with for loops and all but ending up with […arr] :rofl: when all I need to do is remove the brackets…
This is a life saver :wink: