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

1 Answer

0 votes
const str = '13,900,8200.50';

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

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

 



answered Feb 13, 2022 by avibootz

Related questions

1 answer 207 views
1 answer 221 views
1 answer 222 views
1 answer 252 views
1 answer 186 views
...