Skip to content

Instantly share code, notes, and snippets.

@notnek
Last active February 5, 2018 13:51
Show Gist options
  • Save notnek/2b76901b8cf013438f5ec37edd1329da to your computer and use it in GitHub Desktop.
Save notnek/2b76901b8cf013438f5ec37edd1329da to your computer and use it in GitHub Desktop.
1-liner function for building up strings
// https://twitter.com/peterpme/status/950137901198659584
const buildStr = (delim, arr) => arr.filter(i => i).join(delim)
buildString(',', [undefined, 'Illinois']) // Illinois
buildString(' @ ', ['Developer', 'Orchard']) // Developer @ Orchard
buildString('/', ['api', 'users', '123']) // api/users/123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment