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 209 views
1 answer 222 views
1 answer 222 views
1 answer 258 views
1 answer 192 views
...