Skip to content

Instantly share code, notes, and snippets.

@leoherzog
Created July 23, 2016 17:56
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 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");});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment