Slice and Splice - What`s wrong?

Tell us what’s happening:
Why my code is incorrect??
It returning exactly what we need.

Your code so far


function frankenSplice(arr1, arr2, n) {
  // It's alive. It's alive!
  let localArray = [...arr2];
  localArray.splice(n, 0, [...arr1]);
  return localArray;
}
   
console.log(frankenSplice([1, 2], ["a", "b"], 1));

Your browser information:

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

You’re getting the values from arr1 (this bit is fine)…

...arr1

…putting them in an array

[...arr1]

…then spicing that array into the copy of arr2

localArray.splice(n, 0, [...arr1])

You have an extra step there, the second of those three things

1 Like

As last advice, console log your localArray before returning it and check your browser console and you will see

1 Like

Yes, this is important! the FCC console output just showing the values makes it look like it’s correct