Why it doesn`t work?

Why it doesn`t work?
0

#1

Tell us what’s happening:

Why it doesn`t work? Should I use join method?

Your code so far


function frankenSplice(arr1, arr2, n) {
   
   return arr2.splice(n, 0, arr1.slice(0));

}


frankenSplice([1, 2, 3], [4, 5, 6], 1);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/slice-and-splice


#2

You can’t directly return spliced array on the same line.

Save it into a variable and return it on another line.

Also calling arr1.slice(0); will wrap it into an extra array.


#3

Read the instructions in the challenge carefully.
Input arrays should not be modified.
A spilce() method returns:

An array containing the deleted elements.
If only one element is removed, an array of one element is returned.
If no elements are removed, an empty array is returned

See if this helps you in finding out your mistake.