Created
July 23, 2016 17:56
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
For problems like this:
http://stackoverflow.com/questions/38544941/how-to-i-add-in-degree-symbols-to-temperatures-in-a-javascript-string/38544942