fix dollar formatter

This commit is contained in:
Andrew Croce 2018-09-18 09:41:26 -04:00
parent cef2c448e6
commit 651e503a0c

View File

@ -2,7 +2,7 @@ export const formatDollars = (value, cents = true) => {
if (typeof value === 'number') {
return cents
? `$${value.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')}`
: `$${value.toFixed(0).replace(/\d(?=(\d{3}))/g, '$&,')}`
: `$${value.toFixed(0).replace(/\d(?=(\d{3})+(?!\d))/g, '$&,')}`
}
return ''
}