Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add reject #511

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions snippets/reject.md
@@ -0,0 +1,17 @@
### reject

Returns the elements of an array for which the passed function returns `false`.

Use `Array.filter()` and the not operator (`!`) to return the elements in the array for which `fn` returns `false`.

```js
const reject = (arr, fn) => arr.filter((e,i,arr) => !fn(e,i,arr));

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

```

```js
const users = [
{ 'user': 'barney', 'age': 36, 'active': false },
{ 'user': 'fred', 'age': 40, 'active': true }
];
reject(users, o => !o.active); // [{ 'user': 'fred', 'age': 40, 'active': true }]
```
1 change: 1 addition & 0 deletions tag_database
Expand Up @@ -128,6 +128,7 @@ randomNumberInRange:math,utility,random
readFileLines:node,array,string
redirect:browser,url
reducedFilter:array
reject:array,object,function
remove:array
reverseString:string,array
RGBToHex:utility
Expand Down