Slice and Splice - reason for the answer not being accepted

Tell us what’s happening:
Can anyone please hint at what I am doing wrong?
If I console log the result, i am getting the same array as required by the answer, yet somehow it is not being considered right? I want to know the logic behind it being wrong. Thank you!

Your code so far


function frankenSplice(arr1, arr2, n) {
  // It's alive. It's alive!
  var slc = arr1.slice();
  var result = arr2.slice();
  result.splice (n, 0 , arr1.slice());
  
  return result;
} 

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/70.0.3538.77 Safari/537.36.

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

If you look around the forum a bit (especially for this challenge) you’ll see that you’ve run into the same “gotcha” as many other campers. When you console.log() an array, it converts it to a string and therefore obscures the array’s structure. Your code is returning a multi-dimensional array.

2 Likes