Slice and Splice array

Slice and Splice array
0

#1

Tell us what’s happening:

my code is working fine for all test cases in online browser. But when i try to submit in freecodecamp it is showing test cases failed
Your code so far


function frankenSplice(arr1, arr2, n) {
  // It's alive. It's alive!
  let ar = new Array();
  let j=0;
    
  let b=arr2.slice(n);
  
  for(let i=0;i<n;i++)
    {
      ar[j]=arr2[i];
      j++
    }
  
  ar.splice(n,0,arr1);
  ar.push(b);
  document.write(ar);
  return ar;
}

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) 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 are returning this.

[ 4, [ 1, 2, 3 ], [ 5 ] ]

So you are actually putting them into arrays before you return them.