algorithms/dropIt.js
2024-01-12 07:01:06 -05:00

12 lines
215 B
JavaScript

function dropElements(arr, func) {
if (arr.findIndex(func) === -1) {
return [];
}
return arr.slice(arr.findIndex(func));
}
console.log(
dropElements([1, 2, 3], function (n) {
return n >= 5;
})
);