Slice and Splice Not Passing 1 check due to error?

Tell us what’s happening:

I’m getting the correct outputs in the FCC console and the Chrome console.

All of the checks are passing except: “All elements from the first array should be added to the second array in their original order.”

The order looks to correct to me so I’m not sure what else I should be trying to do.

Your code so far


function frankenSplice(arr1, arr2, n) {
  // It's alive. It's alive!
  let ans = arr2.slice();
  arr1.forEach(function(e) {
    ans.splice(n - arr2.length,0,e);
  });
  //console.log(ans);
  return ans;
}

frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2)
frankenSplice([1, 2, 3], [4, 5], 1);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

The problem here is that arr2.length is static, meaning n - arr2.length will always be the same number for each iteration of the loop, but with the logic you are using above you don’t want that, you want the position of the splice (first argument) to be a variable as you alter it’s contents. so make n - arr2.length a variable and you should be good to go, hint: take a look at some of the argumentsof the callback function of forEach()