I have 2,299.00 as a string and I am trying to parse it to a number. I tried using parseFloat, which results in 2. I guess the comma is the problem
2,299.00
parseFloat
const parseLocaleNumber = strNum => { const decSep = (1.1).toLocaleString().substring(1, 2); const formatted = strNum .replace(new RegExp(`([${decSep}])(?=.*\\1)`, 'g'), '') .replace(new RegExp(`[^0-9${decSep}]`, 'g'), ''); return Number(formatted.replace(decSep, '.')); };