Created
September 18, 2014 07:49
-
-
Save heymexa/0e8c20b85c52d4e7f3b9 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
/** | |
* @param {number} sum | |
* @returns {string} | |
* @example | |
* 1234567 -> 1 234 567 | |
*/ | |
function formatNumber (number) { | |
return number.toString().replace(/(\d)(?=(\d{3})+([\D]|$))/g, '$1 '); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment