My code is the following:
function frankenSplice(arr1, arr2, n) {
// It’s alive. It’s alive!
var arr1Copy = arr1.slice();
var arr2Copy = arr2.slice();
for (var i = 0; i < arr1.length; i++) {
arr2Copy.splice(n, 0, arr1Copy[i]);
n++;
}
return arr2Copy;
}
frankenSplice([1, 2], [“a”, “b”], 1);
And I keep getting the following errors:
frankenSplice([1, 2], [“a”, “b”], 1) should return [“a”, 1, 2, “b”].
The first array should remain the same after the function runs.
The second array should remain the same after the function runs.
Can someone please explain to my why? I’m so lost…