Removes and returns numItems
from beginning of array
.
Removes and returns numItems
from end of array
.
let arr = ['jim', 'todd', 'tony', 'barry', 'jill'];
let firstTwo = getAndRemoveHead(2, arr);
// firstTwo is ['jim', 'todd'] .
// arr is now ['tony', 'barry', 'jill'] .
let arr = ['jim', 'todd', 'tony', 'barry', 'jill'];
let lastThree = getAndRemoveTail(3, arr);
// lastThree is [ 'tony', 'barry', 'jill'] .
// arr is now ['jim', 'todd'] .
npm i @writetome51/array-get-and-remove-head-tail
import {getAndRemoveHead, getAndRemoveTail}
from '@writetome51/array-get-and-remove-head-tail';