Basic Algorithm Scripting: Slice and Splice - Why My Code Is Not Accepted

I checked my code on the browser console to see if I am creating a multidimensional array by mistake, but it seems like I am not. However, I could not understand why fcc console does not accept my answer. Can anyone help me to understand. Here is the code:

function frankenSplice(arr1, arr2, n) {
  let arr3 = arr2.slice(0, n);
  return arr3;

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

Edit: The error that I’m getting is as follows:

frankenSplice([1, 2, 3], [4, 5], 1) should return [4, 1, 2, 3, 5].

frankenSplice([1, 2], ["a", "b"], 1) should return ["a", 1, 2, "b"].

frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2) should return ["head", "shoulders", "claw", "tentacle", "knees", "toes"].

All elements from the first array should be added to the second array in their original order.

What is the error you are getting?

can you please tell error or what you suppose to do in your code

I edited the post with error message. I guess this explains what my code is supposed to do.

I tried it again without changing anything and this time it works. So, the problem is not with my code. Sorry for bothering and thank you.

it will clear your error you didn’t splice your error before pushing inside the stack
like below

let localArray = arr2.slice();//array 2 slice first and pass to another array
  for (let i = 0; i < arr1.length; i++) {
    localArray.splice(n, 0, arr1[i]);//here splice need to be done 
    //increament your parameter  n  by 1 or n++
  //return here array

Hope this help