Rail Fence 8 Pt. Star

Custom Splice

Problem Descripton

Create a custom splice function. The function takes 3+ arguments: an array, a starting index, the number of elements to delete, and optional additional arguments to add to the array. The array should be mutated and the function should return the deleted elements. If the starting index is greater than the array length, set it to the array length. If the "delete count" is greater than the difference between the length of the array and the starting point, set it equal to the difference. You may not use Array.prototype.splice().

Solving the Problem

*The blue comments below are examples of the approach.

splice solution splice solution

Rail Fence 8 Pt. Star