Tell us what’s happening:
Hi everyone, I’m just wondering if anyone knows why this code doesn,t pass the test even though I get the correct output every time. I already fixed it by replacing this arr1.slice(i, i+1)
with this arr1[i]
inside the for loop but I just don’t understand why that fixes the issue if still I get the same output.
Thanks in advance for your help.
Your code so far
function frankenSplice(arr1, arr2, n) {
// It's alive. It's alive!
let arr3 = [...arr2];
for(let i = 0; i<arr1.length;i++){
arr3.splice(n++, 0, arr1.slice(i, i+1));
}
return arr3;
}
console.log(frankenSplice([1, 2, 3], [4, 5], 1));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36
.
Link to the challenge: