# Basic Algorithm Scripting: Slice and Splice partially completed

So i have been stuck on this one for a bit. I tried the rubber ducky method of just writing out basic terms of calling the arrays “boxes” and trying to copy the contents of one box into another. However, I only have part of this challenge covered. I am not understanding how to get a full combined array. I’ve tried concat(), and splicing but neither work. Where am I going wrong?

``````

function frankenSplice(arr1, arr2, n) {
arr2 = arr1.slice();
console.log(arr2);
arr2.splice(arr1, n);

return arr2;
}

console.log(frankenSplice([1, 2, 3], [4, 5], 1));
// frankenSplice([1, 2, 3], [4, 5], 1) should return [4, 1, 2, 3, 5].
``````

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

Challenge: Slice and Splice

``````function spliceSlice(arr1, arr2, n){
var ar1=arr1.slice();
ar1.splice(n,0,arr2);
}
var fruits = ["Banana", "Orange", "Apple", "Mango"];
var moreFruit = ["Lemon", "Kiwi"];
spliceSlice(fruits,moreFruit,3);
``````

Thanks. That example makes sense, but it’s inserting two fruits in the middle. The challenge above is confusing for me as it takes the 4 and puts it in the beginning then counts through array 1, and then ends with arrays 2 last element. I am lost on how that is achieved.

``````<script>
function spliceSlice(arr1, arr2, n){
var ar1=arr1.slice();
ar1.splice(n,0,arr2);
}
var fruits = [1,2,3];
var moreFruit = [4,5];
spliceSlice(moreFruit,fruits,1);
</script>
``````
1 Like

Ahhh. I see now. I was slicing the incorrect Array. I had to slice the second array and assign it to a variable. Then splice it ! Thank you very much!!

``````function frankenSplice(arr1, arr2, n) {
let newArr = arr2.slice();
console.log(newArr);
newArr.splice(n, 0, arr1);
console.log(newArr);
console.log(arr1);
console.log(arr2);

return newArr;
}

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

I am quite sure
no working solution