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 213 views
1 answer 228 views
1 answer 227 views
1 answer 263 views
1 answer 196 views
...