So, it’s not working and I need to do some more thinking but I’m not sure why I’m failing the test concerning keeping the original array of arr2.
I have arranged so that array has been kept within keepArr, so that it is preserved. Where am I going wrong with this?
Otherwise, I attempted to save my splice() within the keepArr2 container, but it registers nothing when I console.log it. Yet, when I console.log arr2 it returns something that’s almost a right answer [4,5,1,2,6]
I guess I’m thinking that what I’ve written should really return something entirely different than what is actually returning. I think this is something to do with how I’m using my variable containers but I’m not sure exactly where that fault lies.
function frankenSplice(arr1, arr2, n) {
// Make a copy of the second array
const keepArr = arr2.slice(0,3);
//Make loop to run through first array
for(let i = 0;i < arr1.length; i++){
//splice each items into the array as an argument
if(i>0){
let keepArr2 = arr2.splice(-1,0,i);
}
}
console.log(keepArr2);
return keepArr2;
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);