Tell us what’s happening:
My code seems to output exactly what the challenge wants but for some reason it fails under “All elements from the first array should be added to the second array in their original order.” error and I don’t understand why.
**Your code so far**
function frankenSplice(arr1, arr2, n) {
let newArr = []
for(let i = 0; i < arr2.length; i++){
if(i == n){
newArr.push(...arr1);
newArr.push(arr2[i]);
}else{
newArr.push(arr2[i]);
}
}
return newArr;
}
console.log(frankenSplice([1, 2, 3], [4, 5, 6], 1));
console.log(frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2));
console.log(frankenSplice([1, 2], ["a", "b"], 1));
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36
Challenge: Slice and Splice
Link to the challenge: