Languages
[Edit]
EN

JavaScript - change commas into dots

3 points
Created by:
Inayah-Alexander
767

In this article, we would like to show you how to change commas into dots in JavaScript.

Quick solution:

let x = '0,5';

x = x.replace(/,/g, '.');  // 0.5

 

Practical example

In this example, we change the comma into a dot using regex.

// ONLINE-RUNNER:browser;

let x = '0,5';

x = x.replace(/,/g, '.');

console.log(x);

References

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join