Update takeWhile.md

This commit is contained in:
Angelos Chalaris
2020-11-29 11:23:01 +02:00
committed by GitHub
parent c00348686e
commit e56f346184

View File

@ -3,10 +3,10 @@ title: takeWhile
tags: array,intermediate
---
Removes elements in an array until the passed function returns `true`.
Removes elements in an array until the passed function returns `false`.
Returns the removed elements.
- Loop through the array, using a `for...of` loop over `Array.prototype.entries()` until the returned value from the function is `true`.
- Loop through the array, using a `for...of` loop over `Array.prototype.entries()` until the returned value from the function is `false`.
- Return the removed elements, using `Array.prototype.slice()`.
```js