Created
January 25, 2023 10:53
-
-
Save jelmervdl/69ab3fe42704d9eb4d36089619c0c790 to your computer and use it in GitHub Desktop.
Revisions
-
jelmervdl created this gist
Jan 25, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ 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))