Created
February 24, 2018 23:49
-
-
Save janephilipps/d1768259dbdca00dfcba6245513686f2 to your computer and use it in GitHub Desktop.
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
/* This function takes an integer and returns a | |
* string representation with commas for every group of 3 digits. | |
* See this StackOverflow post for an explanation: | |
* https://goo.gl/gfe1H7 | |
*/ | |
var addCommas = function(number) { | |
return number.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, “,”); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment