Can someone please explain to me why the 4th test is failing?

Tell us what’s happening:

  **Your code so far**

function frankenSplice(arr1, arr2, n) {
return arr2.reduce((acc, item, index) => {
  if(index === n){
    acc.push(...arr1, item)
  } else {
  return acc
}, [])

frankenSplice([1, 2, 3], [4, 5, 6], 1);
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:87.0) Gecko/20100101 Firefox/87.0.

Challenge: Slice and Splice

Link to the challenge:

Hello there,

Add this to your code, and see what is output:

console.log(frankenSplice([1, 2, 3, 4], [], 0));


You are not accounting for base cases (what happens when arr2 is empty)

Hope this helps

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.