Skip to content

Commit 4d917df

Browse files
Merge pull request #108 from Amubasshir/mubasshir
remove falsy value sniped
2 parents fc097aa + 5ec2f78 commit 4d917df

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Remove Falsy Values
3+
description: Removes falsy values like null, undefined, and false from an array.
4+
author: mubasshir
5+
tags: javascript,array,falsy,filter
6+
---
7+
8+
```js
9+
const removeFalsy = (arr) => arr.filter(Boolean);
10+
11+
// Usage:
12+
const array = [0, 1, false, 2, "", 3, null];
13+
console.log(removeFalsy(array)); // Output: [1, 2, 3]
14+
```

0 commit comments

Comments
 (0)