i have a price valor (for example 3,45€) how can i create a function that could replace and create a dynamic output with the dot in place of the comma? and without the "€". (in this example 3.45) thank you
Asked
Active
Viewed 156 times
-3
-
1Have you done any research so far? Replacing characters and extracting numbers from strings are both pretty trivial tasks with many existing and easy to find solutions. – Jul 09 '20 at 08:16
-
`price = price.replace(/^(\d+),(\d+)€$/,'$1.$2');` for instance – Déjà vu Jul 09 '20 at 08:20
1 Answers
0
Try:
let price = "3,45€";
price = price.split(',').join('.').substring(0, price.length - 1);

Rob Bailey
- 920
- 1
- 8
- 23