/./
means that you use regex and .
replaces any character. Try without regex:
ausgabe.replace('.', ',');
Or escape .
:
ausgabe.replace(/\./g, ',');
Вопрос
the following code is a converter from euro to dollar in JS. It is a JS function. eingabe = input, ausgabe = output. If I execute this code I get ,,,,,,,, as an output instead of 1,37.
eingabe = eingabe.replace(/,/g, ".");
eingabe = parseFloat(eingabe);
var kurs_euro = 1.37 // 1 euro = 1,37 dollar
var ausgabe = 0;
ausgabe = eingabe * kurs_euro;
ausgabe = Math.round((ausgabe + 0.00001) * 100)/100 + " Dollar";
ausgabe = ausgabe.toString();
ausgabe = ausgabe.replace(/./g, ",");
alert(ausgabe);
Решение
/./
means that you use regex and .
replaces any character. Try without regex:
ausgabe.replace('.', ',');
Or escape .
:
ausgabe.replace(/\./g, ',');