@@ -22,6 +22,7 @@ All of these examples are from FreeCodeCamp's [course](https://www.freecodecamp.
22
22
- [ 9. Finders Keepers] ( #9-finders-keepers )
23
23
- [ 10. Boo who] ( #10-boo-who )
24
24
- [ 11. Title Case a Sentence] ( #11-title-case-a-sentence )
25
+ - [ 12. Slice and Splice] ( #12-slice-and-splice )
25
26
26
27
## Basic Algorithm Scripting
27
28
@@ -385,3 +386,29 @@ function titleCase(str) {
385
386
386
387
titleCase (" I'm a little tea pot" );
387
388
```
389
+
390
+ ### 12. Slice and Splice
391
+
392
+ _ Difficulty: Beginner_
393
+
394
+ You are given two arrays and an index.
395
+
396
+ Copy each element of the first array into the second array, in order.
397
+
398
+ Begin inserting elements at index n of the second array.
399
+
400
+ Return the resulting array. The input arrays should remain the same after the function runs.
401
+
402
+ ---
403
+
404
+ #### Solution
405
+
406
+ ``` js
407
+ function frankenSplice (arr1 , arr2 , n ) {
408
+ let localArr = [... arr2];
409
+ localArr .splice (n, 0 , ... arr1);
410
+ return localArr;
411
+ }
412
+
413
+ frankenSplice ([1 , 2 , 3 ], [4 , 5 ], 1 );
414
+ ```
0 commit comments