Slice and Splice (Maybe bug?)

Tell us what’s happening:
I don’t know why my code is not accepted, even if it the result is the same as what it is expected.

Your code so far

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

frankenSplice([1, 2], ["a", "b"], 1);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:67.0) Gecko/20100101 Firefox/67.0.

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

Hello @HawkSpectre, welcome to the forum.

Remeber that slice returns a new array, so effectively you are adding a new array in rhe result, instrad of the content of that array :slight_smile:

To give you an example, without spoling the solution here’s what your function returns

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

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

which is close, but not exactly the desired result.
But you’re almost there :+1:

Yes, that’s right. Thank you!