Help with slicing and splicing

Hello all!

I have yet to post a question under the help forum, so please bare with me if my question or post is not too clear. I am working on this challenge, incorporating slicing and splicing arrays. With my current code ran under console.log();, I appear to be receiving the expected result (copying arr1 inside of arr2 at the index of n.) Yet, it will not pass the test. I checked the resolution and they use a for loop to cycle through the array and slice each chunk out of it, through the loop. I understand how that resolution works, but I can’t figure out why mine isn’t considered correct. Maybe by the end of the function, arr1 and arr2 are modified and aren’t in their original state, like the problem specifies they should be? I would appreciate any feedback/guidance. Thanks!

Here’s what my code currently looks like(I sliced both arr1, and arr2, assuming that splicing arr1 into arr2 would modify the original arrays, which the problem doesn’t want to happen):

function frankenSplice(arr1, arr2, n) {
let sliced1 = arr1.slice(0, arr1.length);
let sliced2 = arr2.slice(0, arr2.length);
sliced2.splice(n, 0, sliced1);
return sliced2;


frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2);

You may want to use, instead of console.log(...), console.log(JSON.stringify(...)) and you will see
(If you need more hints asks again without fear)

1 Like

I was completely unfamiliar with JSON.stringify… that makes a huge difference. I can see that I’m putting an array, inside of another array. That makes way more sense. Thank you so much!