# Answer "Doesn't Work" - Slice and Splice

**URL:** <https://forum.freecodecamp.org/t/answer-doesnt-work-slice-and-splice/251085>\
**Category:** General\
**Created:** [January 12, 2019, 7:49pm UTC](https://forum.freecodecamp.org/t/answer-doesnt-work-slice-and-splice/251085 "2019-01-12T19:49:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sh0uri](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sh0uri/32/107882_2.png) [@sh0uri](https://forum.freecodecamp.org/u/sh0uri)\
**Post date:** [January 12, 2019, 7:49pm UTC](https://forum.freecodecamp.org/t/answer-doesnt-work-slice-and-splice/251085/1 "2019-01-12T19:49:51Z")

</div>

**Tell us what’s happening:**  
Not sure why FCC is telling me this answer doesn’t work. It seems to be doing what I understand the prompt is asking me for.

**Your code so far**

```auto

function frankenSplice(arr1, arr2, n) {
  var finalArr = arr2.slice(0);
  console.log(finalArr); //Test that the mutate-able arr2 was copied succesfully.
  finalArr.splice(n, 0, arr1);
  console.log(finalArr); //Test that our answer will work before we hit submit.
  return finalArr;
}

frankenSplice([1, 2, 3], [4, 5, 6], 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`.

**Link to the challenge:**  
htt ps ://lea rn.freecodecamp. org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/slice-and-splice

---

<div class="post-metadata">

**Author:** ![sh0uri](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sh0uri/32/107882_2.png) [@sh0uri](https://forum.freecodecamp.org/u/sh0uri)\
**Post date:** [January 12, 2019, 7:54pm UTC](https://forum.freecodecamp.org/t/answer-doesnt-work-slice-and-splice/251085/2 "2019-01-12T19:54:30Z")

</div>

The FCC-implemented solution is a similar solution to mine, but they use an entire “for loop” that seems extraneous given the prompt. I’m hoping they don’t just want me to implement it that way for no reason.

---

<div class="post-metadata">

**Author:** ![sh0uri](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sh0uri/32/107882_2.png) [@sh0uri](https://forum.freecodecamp.org/u/sh0uri)\
**Post date:** [January 12, 2019, 7:59pm UTC](https://forum.freecodecamp.org/t/answer-doesnt-work-slice-and-splice/251085/3 "2019-01-12T19:59:57Z")

</div>

Upon further evaluation, I’m assuming that implementing the solution my way actually means that the entire arr1 is implemented as 1 array, rather than each individual item. This isn’t shown by using console.log(), however I guess it makes sense. I’m not sure how best to debug array-based problems in the future given this new information

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 12, 2019, 8:25pm UTC](https://forum.freecodecamp.org/t/answer-doesnt-work-slice-and-splice/251085/4 "2019-01-12T20:25:05Z")

</div>

If you use the browser console to debug you can see if something is an array or not

---

<div class="post-metadata">

**Author:** ![sh0uri](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sh0uri/32/107882_2.png) [@sh0uri](https://forum.freecodecamp.org/u/sh0uri)\
**Post date:** [February 16, 2019, 8:13pm UTC](https://forum.freecodecamp.org/t/answer-doesnt-work-slice-and-splice/251085/5 "2019-02-16T20:13:52Z")

</div>

Thank you not sure how to do that but next time it comes up I’ll try and figure it out.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 16, 2021, 12:59pm UTC](https://forum.freecodecamp.org/t/answer-doesnt-work-slice-and-splice/251085/6 "2021-01-16T12:59:27Z")

</div>

Closed on January 16, 2021, 12:59pm UTC


