Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nattatorn-dev/a9d5ae067131dbd60b83130906efd254 to your computer and use it in GitHub Desktop.
Save nattatorn-dev/a9d5ae067131dbd60b83130906efd254 to your computer and use it in GitHub Desktop.
var arr = [0,1,2,3,4];
var g = arr.join(', ').replace(/,(?!.*,)/gmi, ' and');
// result 0, 1, 2, 3 and 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment