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 213 views
1 answer 227 views
1 answer 227 views
1 answer 259 views
1 answer 192 views
...