The if logic inside the loop is wrong. Challenge is to insert to elements of first array at n index of the second array. If you console the output you’ll see that your comparison logic is incorrect. You don’t have to compare elements but look for the n index in the second array.

You can solve it in a single line using spread operator and slice method as follows. (I’ve blurred it)

...arr2.slice(0, n) will return elements upto nth index (excluding n) & will spread the elements. So now we’ve reached the nth index of the arr2. Now we can put the entire arr1 after it.

...arr1 will spread the elements.

...arr2.slice(n) will start slicing from n index upto the length of the arr2.