diff options
Diffstat (limited to 'frontend/lib/formatMoney.js')
| -rw-r--r-- | frontend/lib/formatMoney.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/frontend/lib/formatMoney.js b/frontend/lib/formatMoney.js index edddf48..301f01f 100644 --- a/frontend/lib/formatMoney.js +++ b/frontend/lib/formatMoney.js @@ -1,3 +1,11 @@ -export default function(amount) { - return '$' + (amount / 100).toLocaleString(); +export default function (amount) { + const options = { + style: 'currency', + currency: 'USD', + minimumFractionDigits: 2, + }; + // if its a whole, dollar amount, leave off the .00 + if (amount % 100 === 0) options.minimumFractionDigits = 0; + const formatter = new Intl.NumberFormat('en-US', options); + return formatter.format(amount / 100); } |
