Skip to content

Instantly share code, notes, and snippets.

@farishan
Last active September 11, 2021 09:01
Show Gist options
  • Save farishan/f0aaaf7994c86ef3a427e8d8c612e1aa to your computer and use it in GitHub Desktop.
Save farishan/f0aaaf7994c86ef3a427e8d8c612e1aa to your computer and use it in GitHub Desktop.
Array of strings to a sentence
// Credits: Svelte (from Svelte's Tutorial)
function join(strings) {
if (strings.length === 1) return strings[0];
return `${strings.slice(0, -1).join(', ')} and ${strings[strings.length - 1]}`;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment