Created
September 4, 2021 15:43
-
-
Save ibayazit/33f0bae097998bf834e7f6185dedfe2d to your computer and use it in GitHub Desktop.
JS Currency 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
| const number = 123456.789; | |
| console.log(new Intl.NumberFormat('tr-TR', { style: 'currency', currency: 'TRY' }).format(number)); | |
| // expected output: "₺123.456,79" | |
| // the Japanese yen doesn't use a minor unit | |
| console.log(new Intl.NumberFormat('ja-JP', { style: 'currency', currency: 'JPY' }).format(number)); | |
| // expected output: "¥123,457" | |
| // limit to three significant digits | |
| console.log(new Intl.NumberFormat('en-IN', { maximumSignificantDigits: 3 }).format(number)); | |
| // expected output: "1,23,000" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment