# Basic Algorithm Scripting: Slice and Splice: can anyone say this is not acceptable

in Basic Algorithm Scripting: Slice and Splice I wrote the code as below:

``` function frankenSplice(arr1, arr2, n) { let combinedArr = []; for(let i = 0; i < n; i++){ combinedArr.push(arr2[i]); console.log(combinedArr); } combinedArr.push(arr1); combinedArr.push(arr2.slice(n)); return combinedArr; } ```

It returns right answer. But it is not accepted and I don’t know why?

try using the browser console to see the result of `console.log(combinedArr);` just before you return it

Or with the `console.log()` I have added in the loop at the bottom:

Code
``````function frankenSplice(arr1, arr2, n) {
let combinedArr = [];

for(let i = 0; i < n; i++){
combinedArr.push(arr2[i]);
}

combinedArr.push(arr1);
combinedArr.push(arr2.slice(n));
for (let i = 0; i < combinedArr.length; i++) {
console.log("arr[" + i + "] is " + combinedArr[i]);
}
return combinedArr;
}
``````

you get this:

``````combinedArr[0] is 4
combinedArr[1] is 1,2,3
combinedArr[2] is 5,6
``````

You are not passing because your array has subarrays. Can you find where the issue in your code is?

For your code to pass it needs to appear in the console.log this:

``````combinedArr[0] is 4
combinedArr[1] is 1
combinedArr[2] is 2
combinedArr[3] is 3
combinedArr[4] is 5
combinedArr[5] is 6
``````
3 Likes

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (`</>`) will also add backticks around text.

Note: Backticks are not single quotes.