Remove commas from the string using JavaScript

后端 未结 3 903
名媛妹妹
名媛妹妹 2020-11-29 02:45

I want to remove commas from the string and calculate those amount using JavaScript.

For example, I have those two values:

  • 100,000.00
  • 500,0
3条回答
  •  旧巷少年郎
    2020-11-29 03:05

    This is the simplest way to do it.

    let total = parseInt(('100,000.00'.replace(',',''))) + parseInt(('500,000.00'.replace(',','')))
    

提交回复
热议问题