Created
April 11, 2018 15:01
-
-
Save danielcaldas/bc5d7144cc2ee08bd484890334e08884 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Drops array elements while specified condition is met | |
* @param {Array.<T>} array | |
* @param {Function} cb condition to drop elements | |
* @returns {Array.<T>} returns array tail of resulting operation | |
*/ | |
function dropWhile(array, cb) { | |
const n = array.length; | |
let i = 0; | |
for (; i < n; i++) { | |
if (!cb(array[i])) { | |
break; | |
} | |
} | |
return array.slice(i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment