# Algorithm Scripting: Slice and Splice | What's the problem?

Hi, everyone

i’m trying to figure out simple solution for this problem

but , i don’t now why the editor don’t accept this solution even it’s return the right result ? ?

``````function frankenSplice(arr1, arr2, n) {
// It's alive. It's alive!
let firstElem = arr2.slice(0,n)
let lastElem = arr2.slice(n,);
let fullArry = [firstElem,arr1 ,lastElem]
return fullArry
}

console.log(frankenSplice([1, 2], ["a", "b"], 1)) // a,1,2,b

``````

You’re passing `arr2` as a whole array instead of its individual components. Use the browser console to view this but what you think is `[a,1,2,b]` is actually `[a,[1,2],b]`.

You can also drop in `console.log(frankenSplice([1, 2], ["a", "b"], 1).length)` to verify the length is 3 instead of the 4 it should be.
-J

1 Like

I never thought that there a real different between the FCC console and browser Console and
I think it’s wrong solution because slice represent new array Not just number inside array. So,I’ll try to figure out new solution to solve that problem.
Thank you again.

1 Like

Hey,@JesseHope
Thank you again

Your idea help me again to figure out the solution with the same code

since slice create new array and we need the items inside array (Not the array itself) So, i used spread operator to copy item inside the new array

I just write this to help other people who may see this problem
Thanks again

1 Like

@eslam You’re welcome!

You should edit your above post and wrap the code with [spoiler][/spoiler] tags. That blurs the text but you can see it if you click on it like this!. In case someone is looking for advice in the future but not the answer.
-J

It is great you solved the challenge! I have blurred out your code to avoid spoiling a full working solution for other campers who may not yet want to see a complete solution.
Thank you.

2 Likes

Sorry about that, i forget to put my code inside spoiler tag,
Thanks you for remind me and edit my reply

In general, avoid posting solutions (even if you add spoiler tags). Just give hints and related examples. Some people don’t understand what the blurred section means and go ahead and click on it and then have the solution spoiled for them.

Thank you.

1 Like

I think your right we should just use hint to help people to thinking about their own solution

I removed the whole solution and just leave some hint to help other to thinking

Thank you

1 Like