Slice and Splice, not passing tests

Tell us what’s happening:
As far as I can tell, my code correctly returns an array, with the elements in the correct order, and inserted at the correct index. But I’m unable to pass the tests. Could someone have a look at my code and hint at where I’ve gone wrong?

Your code so far

function frankenSplice(arr1, arr2, n) {

let newArray = arr2.slice();
newArray.splice(n, 0, arr1);

return newArray; 


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/75.0.3770.142 Safari/537.36.

Link to the challenge:

Hello, sometimes you have to check the console of your Browser, look at this.

This is with the first test, where [4, 1, 2, 3, 5] should be returned, but as you can see in this image, [4, [1,2,3], 5] is being returned.


Thank you! I see it returned the array instead of the elements within the array. Guess I’ll change the code then.

I unpacked arr1 and that seemed to do the trick!

1 Like