# How to write more streamlined code (Basic Algorithm Scripting - Slice and Splice)

Tell us what’s happening:

A bit of background: I am just starting on my coding journey, and have been at it for about a week after having learned only some basic Python a good few years ago. I have gone through the HTML/CSS course, and am now doing the JavaScript work and going through the algorithm scripting section.

See below for some code that I have written.

I have made a habit of trying to supercharge my learning by having a look at the model answers after finding my own answer, and often find that my code is much longer and perhaps not as streamlined. I’ve included a link to the hints page with the solutions to this challenge below for ease.

I tend to use iterative loops instead of functions such as `splice`. I am not finding that I am unable to solve the problems (in the example below, I believe the code accomplishes the task in all cases and passes all tests), but it seems perhaps too complex.

Part of the reason for this is a lack of familiarity with or knowledge of the existence of these more complex methods. Is this something I should be sitting down and memorising, or is it something that just takes time? Is there anything I should be doing to speed up this process?

And, finally, is this even something that I should be worrying about, or should I just be content if the code solves the problem?

``````function frankenSplice(arr1, arr2, n) {
let solutionArray = [];
let newArray = [...arr2];
for (let i = 0; i < n; i++) {
solutionArray.push(arr2[i]);
newArray.shift();
};
solutionArray.push(...arr1);
solutionArray.push(...newArray);
return solutionArray;
}
``````

Challenge: Basic Algorithm Scripting - Slice and Splice