diff --git a/js/script.js b/js/script.js index c009be9..f54b0fb 100644 --- a/js/script.js +++ b/js/script.js @@ -53,7 +53,12 @@ function startNotenrechner() { const punkte = Number(prompt("Wie viele Punkte hast du erreicht?")); const max = Number(prompt("Maximale Punktzahl?")); - const prozent = (punkte / max) * 100; + if (max === 0 || isNaN(max) || isNaN(punkte)) { + alert("Bitte gültige Zahlen eingeben!"); + return; + } + + const prozent = Math.round((punkte / max) * 100); const ergebnis = punkte + " von " + max + " Punkten (" + prozent + "%) = " + berechneNote(punkte);