Slice arr2 and copy at n index of arr1

Slice arr2 and copy at n index of arr1
0

Tell us what’s happening:
My solution does not pass the challenge’s test…
However, the results returned are in line with the challenge’s requirements.
Am I missing anything?
Why isn’t this solution a valid solution?
Thank you!

Your code so far

 let result = arr2.slice();  
  result.splice(n, 0, arr1); 
  return result; 

```js

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

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36 OPR/62.0.3331.43.

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

Try using the browser console or console.log(JSON.stringify(...)) and you will see

1 Like