From 560337626737b8248d0081c565cc8c25cb83551d Mon Sep 17 00:00:00 2001 From: Lena Date: Sun, 31 May 2026 10:43:33 +0200 Subject: [PATCH] =?UTF-8?q?Notenrechner=20ausf=C3=BChrbar=20machen=20(bish?= =?UTF-8?q?er=20passiert=20nichts)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/script.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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);