trying to format decimal places with commas returns white screen

107 views Asked by At

I am trying to simulate a decimal place with Commas to get something like this 1,234,567.90 in turn, I get a white screen. The code I Use is looking like this

Balance&nbsp;&nbsp;&nbsp; </font></td>
<td width="24%" align="left" rowspan="2">
    <font face="Arial Black" size="2">&nbsp;&nbsp;&nbsp;&nbsp; {numberWithCommas(accDetails.bal.toFixed(2))} Currency = {accDetails.ccy}</font><p />
    <font face="Arial Black" size="2">&nbsp;&nbsp;&nbsp;&nbsp; </font>
</td>

And the function I use looks like this:

const numberWithCommas = (x) => {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}

This returns a white screen, I don't even get to see the Error but the Error comes trying to format decimal places for Money in react JS. I need help here.

0

There are 0 answers