Skip to content

Instantly share code, notes, and snippets.

@rchipka
Last active October 1, 2019 16:16
Show Gist options
  • Select an option

  • Save rchipka/af8ebf11719ac5e36d429f1d64805b93 to your computer and use it in GitHub Desktop.

Select an option

Save rchipka/af8ebf11719ac5e36d429f1d64805b93 to your computer and use it in GitHub Desktop.
Concise JavaScript natural language array join sentence
[values.pop(), values.join(', ')].filter(v => v).reverse().join(' and ')
// ['this'] => 'this'
// ['this', 'that'] => 'this and that'
// ['this', 'that', 'the other'] => 'this, that and the other'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment