Tell us what’s happening:
Hi, with my code, I am able to achieve the requirement. Example, frankenSplice([“claw”, “tentacle”], [“head”, “shoulders”, “knees”, “toes”], 2) gives me [“head”, “shoulders”,“claw”, “tentacle”, “knees”, “toes”] in the console. However, it fails the pass the first 4 test cases. I saw the solution where the arr1 is looped and every item is added individually into the second array while incrementing the position ‘n’ every time. I have achieved the solution without the for loop. Could someone please explain why my code does not pass the test cases?
Your code so far
function frankenSplice(arr1, arr2, n) {
// It's alive. It's alive!
var arr4 = [...arr2];
console.log(arr4);
arr4.splice(n, 0, [...arr1]);
console.log(arr4);
return arr4;
}
frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
.