function frankenSplice(arr1, arr2, n) {
// It's alive. It's alive!
return arr2.splice(n,arr1.length-1, ...arr1);
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);
If you heads over Splice() return value in the official docs you will see that the methods returns:
An array containing the deleted elements. If only one element is removed, an array of one element is returned. If no elements are removed, an empty array is returned.
This means you are returning the removed elements, and not the “newly” created one.
Also please note that one of the challenge requirement is
The input arrays should remain the same after the function runs
But since you are using splice
, that changes the array in place, you won’t pass this requirement as well.
Hope this helps