Created
January 25, 2023 10:53
-
-
Save jelmervdl/69ab3fe42704d9eb4d36089619c0c790 to your computer and use it in GitHub Desktop.
Pointless exercise in expressing the difference of an oxford comma
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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