Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to format Number to Currency without decimal point in JavaScript?

Tags:

javascript

var computeST = 2145523
var resultFormat= <-- format the computeST here -->
alert(resultFormat);

the display alert should be

2,145,523

Anyone can help me?

like image 797
Jeff Avatar asked Feb 01 '26 05:02

Jeff


1 Answers

To display price/currency without decimal point or fraction digits, use Intl.NumberFormat with a few parameters maximumFractionDigits and minimumFractionDigits set to 0.

An example:

new Intl.NumberFormat(undefined, { 
  style: 'currency', 
  currency: 'USD',
  maximumFractionDigits: 0, 
  minimumFractionDigits: 0, 
}).format(1050.55)
like image 67
Maksim Shamihulau Avatar answered Feb 02 '26 19:02

Maksim Shamihulau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!