3

I was looking for a JavaScript built-in specifier to convert number in currency, but concluded that there is nothing built-in...

So, Does JavaScript really has no currency format specifier?

Meanwhile, I did a Google search and found that the following lines of code does this job

.ToFixed(0).replace(/./g, function(c, i, a) {
    return i && c !== "." && ((a.length - i) % 3 === 0) ? ',' + c : c;
});

Any other / better way to convert number to currency with some understandable lines of code?

Please advise.

meskobalazs
  • 15,741
  • 2
  • 40
  • 63
TheKingPinMirza
  • 7,924
  • 6
  • 51
  • 81

1 Answers1

0

To parse numbers into a formatted stringwith Javascript.

In browser, or node

numeraljs.com/

openexchangerates.github.io/accounting.js/

node only

github.com/joeferner/node-sf

github.com/fhellwig/strformat

Currency format helper

github.com/Alir3z4/node-money-currencies

  • 1
    If you're just going to recommend libraries, at least show some example code how to use them – Mulan May 10 '15 at 09:57