Slice and Splice: log identical to answer but not passing

So I’ve used the solution in the hint section and it passes. I’ve also used the below code using the spread operator on the splice(’…arr1’ instead of just ‘arr1’) and it passes.

Which would be fine but the below code gives the exact same console log as they do and it matches the stated correct answer for every check but doesn’t pass them.

For example, all 3 code blocks log:

head,shoulders,claw,tentacle,knees,toes

for the example in the code but only the below code fails that check.

Is there an ‘under the hood’ difference I don’t understand yet? or have I just missed something obvious?

Thanks

Edit: I’ve also used ‘typeof’ to make sure its an object.
Your code so far


function frankenSplice(arr1, arr2, n) {
  let arp2 = [] 
  arp2 = arr2.slice();
  arp2.splice(n,0,arr1);
  return arp2;
}
console.log(frankenSplice(["claw","tentacle" ], ['head', 'shoulders', 'knees', 'toes'], 2));

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

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

Open Your browser console by pressing F12 key in your browser.

Copy this code in that console and see what result you get.
That might help you identify your error.

Hint : Error has to do with

this line.
Does that help?

1 Like

Yeah, I get it now. Thanks.

I am glad that i could help.