How to replace a comma with a dot in JavaScript

2 Answers

0 votes
let str = '7,849,127,091';

str = str.replaceAll(',', '.');

console.log(str); 
  


  
/*
run:
  
"7.849.127.091"
  
*/

 



answered May 21, 2022 by avibootz
0 votes
let str = '7,849,127,091';

str = str.replace(/,/g, '.')

console.log(str); 
  


  
/*
run:
  
"7.849.127.091"
  
*/

 



answered May 21, 2022 by avibootz

Related questions

1 answer 183 views
1 answer 198 views
1 answer 198 views
2 answers 245 views
2 answers 219 views
...