Challenge as above
const [a,b, ...arr] = list;
allows the input array to have it’s first two elements ‘‘taken out’’ and the remaining elements given as arr.
I wanted to play around with this - how would one achieve the opposite, that is, I want the last two elements of any array taken out and all elements before that to be it’s own array.
I thought this would be sufficent:
const[...arr ,a,b] = list;
Or say, you wanted to take out the first two elements and the last two elements but evertyhing in the middle is its own array like:
const [a,b, ...arr , x , y] = list;
Of course, thesedoesn’t work which is why I’m asking now, ha.