How to parse a string with commas to a number in Node.js

1 Answer

0 votes
const str = '17,970,8200.50';

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

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

 



answered Feb 13, 2022 by avibootz

Related questions

1 answer 173 views
1 answer 199 views
3 answers 190 views
2 answers 135 views
2 answers 209 views
209 views asked Feb 27, 2020 by avibootz
3 answers 211 views
211 views asked May 24, 2022 by avibootz
...