Slice and Splice not passing test

Slice and Splice not passing test


So i ran my code and it failed, so then i inserted console.log statements to see the result of my slicing and splicing and it returns the correct array but when i run the test it fails. Then i looked at the solution and inserted the same console.log statements to see what their output was and we have the exact same output. Please take a look, here’s my code, i left the console.log statements in it:

function frankenSplice(arr1, arr2, n) {
  // It's alive. It's alive!
  let arr3 = arr2.slice();
  return arr3;

frankenSplice(["a","b"], [4, 5, 6, 7, 8, 9], 4);

Link to the challenge:


The problem is in the following line where you are inserting an array arr1 inside of splice instead of its elements.

The solution is to find a way to extract the elements of the array: arr1 and then pass them to splice.

And here’s a hint: There are many ways to do that, but the easiest of them is an ES6 feature.


what if i used …arr1 instead ?


Yes! the spread operator, the ES6 feature.