# Slice and Splice -

Slice and Splice -
0

#1

Tell us what’s happening:

please can someone go through this solution i don’t know what is wrong with the solution i did what i followed the instruction as instructed

Your code so far

``````
function frankenSplice(arr1, arr2, n) {
// It's alive. It's alive!
let arr = arr2.slice();
arr.splice(n, 0, arr1);
arr.join();
console.log(arr.join());

}

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

#2

You have made a couple of mistakes.

You are on the right track, but that last argument arr1 in your splice method needs to be the array elements of arr1 and not the actual arr1 array. After the first two arguments passed to the splice method, it will take one more argument values, so you will need to think of a way to separate arr1 array into values to pass as arguments. You have learned about the spread operator which would be very useful in this situation.

The join method converts an array to a string. That is not what you want to do. Hint: Your function needs to return something (an array). Currently, it is not explicitly returning a value.

#3

function frankenSplice(arr1, arr2, n) {
// It’s alive. It’s alive!
let arr = arr2.slice();
for(var i in arr1){
arr.splice(n, 0, arr1[i]);
}
console.log(arr);
return arr
}

frankenSplice([1, 2, 3], [4, 5], 1);
frankenSplice([“claw”, “tentacle”], [“head”, “shoulders”, “knees”, “toes”], 2)
i tried another method with this still i cant pass the test despite checking through google chrome console and it gave the same reply as the answer should be

#4

The test case of frankenSplice([1, 2, 3], [4, 5], 1); should return [4, 1, 2, 3, 5]. Your function returns [ 4, 3, 2, 1, 5]. The order of the arr1 still needs to be kept.

#5

function frankenSplice(arr1, arr2, n) {
// It’s alive. It’s alive!
let arr = arr2.slice();
for(var i = arr1.length-1; i >= 0; i–){
arr.splice(n, 0, arr1[i]);
}
console.log(arr);
return arr
}

frankenSplice([1, 2, 3], [4, 5], 1);
frankenSplice([“claw”, “tentacle”], [“head”, “shoulders”, “knees”, “toes”], 2)
thanks i have fixed it with this. Thank you very much for your time.