Slice and Splice, solution feedback

Hello. This is my first post in forum. :slight_smile:

Wanted to ask whether my solution for “Slice and Splice” challenge is good enough:

function frankenSplice(arr1, arr2, n) {
// It’s alive. It’s alive!
let arrStart = arr2.slice(0, n);
let arrEnd = arr2.slice(n);
let newArr = arrStart.concat(arr1, arrEnd);
return newArr;
}
frankenSplice([“claw”, “tentacle”], [“head”, “shoulders”, “knees”, “toes”], 2);

Thanks for feedback!

Did it pass? That’s the surest way to know if it’s good enough.

Words of advice, though, the mods are starting to take a hard look at solutions being posted in the forums (fora?) – when the answer is right there, it becomes less of a challenge for others coming along behind you.

If you have specific questions about why some code DOESN’T work, or something like that, go ahead and post the code and question. Often, when I post suggestions or code hints, I will wrap them in spoiler tags, to make it easier for those coming along to have to deliberately un-hide them. But really, don’t post complete solutions to the boards.

Sorry, i hidden it. I want to know is there is more “optimized” or cleaner solution for it.

Have you learned about the spread operator (looks like ... ) yet?

Yes, i had some tutorials about it.

In that case, I’ll PM you a much more succinct solution. That will keep it off the public board. Yes, your answer works fine. Just… always another way. :wink:

1 Like