Tell us what’s happening:
My code returns the correct input for every test case (verified via console). I ensured that the 2 original input arrays remain unchanged. Yet it is still failing the test, specifically on all elements from the first array should be added to the second array in their original order - which it does btw. Any thoughts?
Your code so far
function frankenSplice(arr1, arr2, n) {
// It's alive. It's alive!
//copy arr2 to arr3 to leave arr2 in tact
var arr3 = arr2.slice();
// Take a copy of arr1 (with slice) and insert into arr3 (with splice) at the supplied index, n
arr3.splice(n,0,arr1.slice());
console.log(arr3);
//return result array, arr3
return arr3;
}
frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/slice-and-splice