Write .dropWhile()

This commit is contained in:
marleyrae 2023-06-27 19:09:40 -07:00
parent a077736466
commit 0f1839555d

View file

@ -70,5 +70,13 @@ _.findKey = function (obj, cb) {
_.drop = (arr, num = 1) => arr.slice(num)
/* ----------------------------------------------------------- dropWhile ---- */
_.dropWhile = function (arr, cb) {
const dropTo = arr.findIndex((e, i) => !cb(e, i, arr))
return this.drop(arr, dropTo)
}
// Do not write or modify code below this line.
module.exports = _