From 99db0b62ccff27c94e371072a7a207203e30b0fc Mon Sep 17 00:00:00 2001 From: srilekha279 <158455553+srilekha279@users.noreply.github.com> Date: Thu, 8 Aug 2024 19:33:56 +0530 Subject: [PATCH] Fixed the bug --- Calculators/Pythagorean-Theorem-Calculator/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Calculators/Pythagorean-Theorem-Calculator/script.js b/Calculators/Pythagorean-Theorem-Calculator/script.js index d799195c7..56b09d5c3 100644 --- a/Calculators/Pythagorean-Theorem-Calculator/script.js +++ b/Calculators/Pythagorean-Theorem-Calculator/script.js @@ -2,12 +2,12 @@ function calculate() { var sideA = parseFloat(document.getElementById('sideA').value); var sideB = parseFloat(document.getElementById('sideB').value); - if (isNaN(sideA) || isNaN(sideB)) { - alert("Please enter valid numerical values for side A and side B."); + if (isNaN(sideA) || isNaN(sideB) || sideA <= 0 || sideB <= 0) { + alert("It looks like one or both of your inputs are missing or not positive. Please enter positive values for both sides."); return; } var sideC = Math.sqrt(Math.pow(sideA, 2) + Math.pow(sideB, 2)); document.getElementById('result').innerHTML = "The length of side C is: " + sideC.toFixed(2); -} \ No newline at end of file +}