Last active
November 30, 2024 18:35
-
-
Save mesuutt/7d8e74f3310d502046d64ec2f45673c0 to your computer and use it in GitHub Desktop.
Format money as Turkish money format.
This file contains hidden or 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
Merhaba React ile tam tersini yapmak için arama yaparken denk geldim.
İstersen aşağıdaki kodu kullanabilirsin.
Ayrıca yuvarlama
FractionDigits
ayarlarını tanımlarsan yuvarlama işlemlerini de yapıyor.0.015=>0.02
0.014=>0.01