Remove commas from string using javascript

I want to remove commas from a string and compute them using javascript.

For example: I have these two values ​​-

  • 100,000.00
  • 500,000.00

Now I want to remove the comma from this line and I want the total amount to be like that.

Thanks in advance.

+72
javascript
Apr 26 2018-11-11T00:
source share
1 answer

To remove commas, you will need to use replace in the string. To convert to float so you can do the math, you need parseFloat :

 var total = parseFloat('100,000.00'.replace(/,/g, '')) + parseFloat('500,000.00'.replace(/,/g, '')); 
+138
Apr 26 2018-11-11T00:
source share
— -



All Articles