Languages
[Edit]
EN

JavaScript - change commas into dots

3 points
Created by:
Inayah-Alexander
407

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

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