Skip to content

Instantly share code, notes, and snippets.

@leoherzog
Created July 23, 2016 17:56
Show Gist options
  • Save leoherzog/a703fa86ddb5cedaf4073fcb5fa2bbb6 to your computer and use it in GitHub Desktop.
Save leoherzog/a703fa86ddb5cedaf4073fcb5fa2bbb6 to your computer and use it in GitHub Desktop.
One-Liner Javascript Code to Add in Degree Symbols to Temperatures in a String
variable = variable.replace(/[0-9]{1,3}F/g, function addDegreeSymbol(x){return x.replace("F", "°F");});
variable = variable.replace(/[0-9]{1,3}C/g, function addDegreeSymbol(x){return x.replace("C", "°C");});
@leoherzog
Copy link
Author

leoherzog commented Jul 23, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment