EN
JavaScript - change commas into dots
3
points
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);