@@Rolf B
function getInputAsFloat(element) { let input = parseFloat(element.value.replace(/,/ , ".") ); return (isNaN(input)) ? 0 : input; }
Wie ich an anderer Stelle schon schrieb, braucht man die die Abfrage isNaN(input) gar nicht:
function getInputAsFloat(element) {
const input = parseFloat(element.value.replace(/,/ , ".") ) || 0;
return input;
}
Und da sich input nicht ändert: const, nicht let. Aber die Variable braucht man gar nicht:
function getInputAsFloat(element) {
return parseFloat(element.value.replace(/,/ , ".") ) || 0;
}
replace() braucht man auch nicht, wenn das Eingabefeld type="number" ist:
function getInputAsFloat(element) {
return element.valueAsNumber;
}
Und damit braucht man die Funktion getInputAsFloat() auch nicht.
🖖 Stay hard! Stay hungry! Stay alive! Stay home!
--
Vielen Eltern dämmert beim Home-Schooling so langsam die Erkenntnis: Lehrer ist wohl doch ein regelrechter Beruf! (@heuteshow)
Vielen Eltern dämmert beim Home-Schooling so langsam die Erkenntnis: Lehrer ist wohl doch ein regelrechter Beruf! (@heuteshow)