Slice and Splice - Can't see the problem with this code

Tell us what’s happening:
Based on the results in the FCC console, my code is returning the right values - but it’s not passing the test, and I can’t tell why. Is the FCC not displaying accurate results?

Your code so far

function frankenSplice(arr1, arr2, n) {
  // It's alive. It's alive!
  let first = arr2.slice(0,n);
  let second = arr2.slice(n);
  for (var i = 0; i < arr1.length; i++) {
    var element = arr1.slice(i,i + 1);
  return first; 

console.log(frankenSplice([1, 2, 3], [4, 5], 1));
console.log(frankenSplice([1, 2], ["a", "b"], 1));
console.log(frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:62.0) Gecko/20100101 Firefox/62.0.

Why don’t you check what your code does using this tool?

1 Like

You are creating a multi-dimensional array. You should have a flat array. Because of the way the arrrays are printed in the browser console, this isn’t obvious. You can see it by wrapping your frankenSplice call in JSON.stringify() or by using a REPL environment like the one linked below.

1 Like

Thanks! I’ll remember this one.

thanks! - now to fix. hmmm…