const cutOffFirstAndLastFive = (array) => {
const [first, ...rest] = array;
return rest.slice(-5);
}
cutOffFirstAndLastFive([1, 55, 77, 88]);
console.log(
'Tests:',
JSON.stringify(cutOffFirstAndLastFive([1, 55, 77, 88])),
JSON.stringify(cutOffFirstAndLastFive([1, 55, 77, 88, 99, 22, 33, 44])),
JSON.stringify(cutOffFirstAndLastFive([1]))
);