Created
January 23, 2019 12:56
-
-
Save rochabianca/eee88b6751dc464301def0f14da4f738 to your computer and use it in GitHub Desktop.
format a number without putting decimals (something like that)
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
let num = 24674 | |
const formattedNum = num.toFixed(0).replace(/(\d)(?=(\d{3})+$)/g, "$1.") // if you want to use commas instead of dots, you can | |
// replace the "$1." to "$1," | |
console.log(formattedNum) // 24.674 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment