Skip to content

Instantly share code, notes, and snippets.

@chrislaughlin
Created January 2, 2017 22:54
Show Gist options
  • Save chrislaughlin/0228d93fd0d4efea42a8f6de8f4eb837 to your computer and use it in GitHub Desktop.
Save chrislaughlin/0228d93fd0d4efea42a8f6de8f4eb837 to your computer and use it in GitHub Desktop.
String Replace
const myString = "This string has many spaces";
console.log(myString.replace(/ /,""));
//"Thisstring has many spaces"
console.log(myString.replace(/ /g,""));
//"Thisstringhasmanyspaces"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment