Hi! I have a problem with this task. After testing and finally creating the new array correctly, the last test (The second array should remain the same after the function runs. )fails.
I tried different variations with putting the args in new vars or just skip the newArr and do the directly in the arr2, but all of them can’t pass the last test. Someone know how to fix this=
function frankenSplice(arr1, arr2, n) {
let newArr = [];
for (let i = 0; i < arr1.length; i++){
newArr = arr2.splice(n, 0, arr1[i]);
n++;
}
return newArr;
}
console.log(frankenSplice([1, 2, 3], [4, 5, 6], 1));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36
Challenge: Basic Algorithm Scripting - Slice and Splice
Link to the challenge: