Last active
April 23, 2024 17:57
-
-
Save mesuutt/7d8e74f3310d502046d64ec2f45673c0 to your computer and use it in GitHub Desktop.
Format money as Turkish money format.
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
function formatMoney(n) { | |
return parseFloat(n).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, '$1.').replace(/\.(\d+)$/,',$1'); | |
} | |
formatMoney(1234567) // 1.234.567,00 | |
formatMoney(1234567.99) // 1.234.567,99 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment