Tell us what’s happening:
I did a very basic solution to this but i wish to know how could i have solved it using slice and splice both as i have used only splice(). (I don’t get slice() properly.)
Any other approach is totally welcome.
Imagine a loaf of bread (and english loaf of bread). You want to “slice” it. If you slice the whole loaf you end up still having the whole loaf but in pieces right? That’s essentially what slice does if you give it zero arguments. If you give it some arguments it returns a new array with a section (some slices) of the old array.
So that is what slice does. You coud combine slice and splice together to chain them and copy the array then splice the other array into it at the correct spot.
Ps. I should point out that you could have used spread more concisely as well like this
let newArr=[…arr1];