Skip to content

Instantly share code, notes, and snippets.

@jelmervdl
Created January 25, 2023 10:53
Show Gist options
  • Save jelmervdl/69ab3fe42704d9eb4d36089619c0c790 to your computer and use it in GitHub Desktop.
Save jelmervdl/69ab3fe42704d9eb4d36089619c0c790 to your computer and use it in GitHub Desktop.
Pointless exercise in expressing the difference of an oxford comma
const joinA = (strs) => [...strs.slice(0,-1), `and ${strs[strs.length-1]}`].join(', ');
const joinB = (strs) => `${strs.slice(0,-1).join(', ')} and ${strs[strs.length-1]}`;
const strs = new Array(10).fill().map((_, i) => (i + 1).toString());
console.log(joinA(strs))
console.log(joinB(strs))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment