How can I parse a string with a comma thousand separator to a number?

e.g, if you try to parseInt (111,222) you ll get the value as 111. To solve this issue we have to use regex and reformat the value.

var numberWithComma = "111,222";
var res = parseFloat( numberWithComma.replace(/,/g, ''));
console.log(res); //111222

Leave a comment

Your email address will not be published.