Search code examples
javascriptstr-replace

i want to remove coma and plus (+) operator from a string


I want to remove plus(+) sign and coma from a string. here is the code.

actualValue.push(parseFloat(wholeValues[i].replace(/,/g, '')))

Solution

  • You just need to replace twice.

    const value = parseFloat(wholeValues[i].replaceAll(',', '').replaceAll('+', ''))
    actualValue.push(value)