Does JavaScript have a currency format specifier?
I was looking for a built-in JavaScript specifier to convert a number to currency, but I came to the conclusion that there is nothing built-in ...
So, doesn't JavaScript really have a currency format specifier?
Meanwhile, I did a google search and found the following lines of code do the 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 a number to currency with some clear lines of code?
Please advise.
+3
source to share
1 answer