Is there a built in function of JavaScript to convert a string into a currency format?
For example
var a = \'1234\'; a.convertToCurrency(); // retu
Although this is an old post. Nonetheless, this worked in for me in my own case:
var a = parseInt("1234"); console.log("$"+number_format(a)); var number_format = function(total) { return total.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); };