Created
April 3, 2023 07:45
-
-
Save martinratinaud/c1d87363383115c62c598a5d903e41d3 to your computer and use it in GitHub Desktop.
One Liner to filter empty values from an array
This file contains hidden or 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
// One-Liner to filter all empty values from an array | |
const words = ["Follow", undefined, "@martinratinaud", null, '', "now!"] | |
const sentence = words.filter(Boolean) | |
console.log(sentence.join(" ")) // Follow @martinratinaud now! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment