Skip to content

Instantly share code, notes, and snippets.

@Chuloo
Created January 29, 2019 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chuloo/a4fb7590db766a9e5d1a393abfc1a9b6 to your computer and use it in GitHub Desktop.
Save Chuloo/a4fb7590db766a9e5d1a393abfc1a9b6 to your computer and use it in GitHub Desktop.
Remove all commas in a string
// new string with commas
const stringWithCommas = 'I, want, to, come, home';
// split string by the commas into an array
const wordArray = stringWithCommas.split(', ')
// join array into a string with a space as separator.
const stringWithoutCommas = wordArray.join(' ');
// display new string
console.log(stringWithoutCommas)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment