Slice and Splice Finding answer

function frankenSplice(arr1, arr2, n) {
  // It's alive. It's alive!
   let newArray="";
   newArray=arr2.slice();
   for (let i = 0; i < arr1.length; i++) {
    newArray.splice(n, 0, arr1[i]);
    n++;
  }
  return newArray;
}

console.log(frankenSplice([1, 2, 3], [4, 5], 1));

this code give frankenSplice([1, 2, 3], [4, 5], 1) should return [4, 1, 2, 3, 5] . this result
But

function frankenSplice(arr1, arr2, n) {
  // It's alive. It's alive!
   let newArray="";
   newArray=arr2.slice();
   newArray.splice(n,0,arr1);
  return newArray;
}

console.log(frankenSplice([1, 2, 3], [4, 5], 1));

this code give frankenSplice([1, 2, 3], [4, 5], 1) should return [4, 1, 2, 3, 5] . this result as well. Now my question why the last solution is not accepted as an answer. where is the problem? can anyone help me, please?

You should use the browser console more often, it is really useful and not subject of the fcc editor console limitations
Your returned value is a multidimensional array, you are copying in the whole array, not its items as you should

1 Like

thank you for the help