How to remove decimals?
Closed this issue · 2 comments
stefdelec commented
Thanks for your great library. Easy and reliable.
I am trying to display
100 => $100 and not $100,00.
How to achieve it ?
Thanks.
stefdelec commented
My quick fix for now :
const removeDecimals=(formattedPrice, decimalCharacter)=> {
const reg = '[' + decimalCharacter + ']{1}[0-9]*';
const regex = new RegExp(reg);
return formattedPrice.replace(regex, '');
}
osrec commented
Hi there!
The easiest way to do this is to define a pattern with no zeros after the dot (the dot is the decimal separator):
OSREC.CurrencyFormatter.format(123.9, { pattern: "#,##." });
There is a little bug in the library which means you still need to insert the dot, even if there are no zeros after it. We will fix this and release shortly :)