How to parse a string with commas to a number in TypeScript

1 Answer

0 votes
const str = '15,990,8200.50';

const num = parseFloat(str.replace(/,/g, ''));

console.log(num); 
 
 
 
 
 
/*
run:
 
159908200.5 
 
*/

 



answered Feb 13, 2022 by avibootz

Related questions

1 answer 120 views
1 answer 129 views
1 answer 131 views
1 answer 147 views
1 answer 113 views
...