Skip to content

Instantly share code, notes, and snippets.

@mesuutt
Last active April 23, 2024 17:57
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save mesuutt/7d8e74f3310d502046d64ec2f45673c0 to your computer and use it in GitHub Desktop.
Save mesuutt/7d8e74f3310d502046d64ec2f45673c0 to your computer and use it in GitHub Desktop.
Format money as Turkish money format.
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