//This is what I tried to do....
function frankenSplice(arr1, arr2, n) {
let newArr = arr2.slice()
return newArr.splice(n,0,...arr1);
//using return on this line doesn't work
}
//-----------------------------------------------
//This is the solution 2 in the Get a Hint! section
function frankenSplice(arr1, arr2, n) {
let localArr = arr2.slice();
localArr.splice(n, 0, ...arr1);
return localArr;
//using return this time after splice works!! Why??
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);
I tried to do the same as in the solution buy I tried to return the code and it didn’t work but when I saw the solution and the code worked when using return after the method has been applied.
Using return in different question with a long line of methods applied to array or strings worked in other questions but not in this one .
Could anyone tell me why??