Skip to content

Instantly share code, notes, and snippets.

@martinratinaud
Created April 3, 2023 07:45
Show Gist options
  • Save martinratinaud/c1d87363383115c62c598a5d903e41d3 to your computer and use it in GitHub Desktop.
Save martinratinaud/c1d87363383115c62c598a5d903e41d3 to your computer and use it in GitHub Desktop.
One Liner to filter empty values from an array
// 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