From d4df5840d4017f66fb8d042f592c1834476b5343 Mon Sep 17 00:00:00 2001 From: Vidhisha Katariya <99196797+VIDHISHAK15@users.noreply.github.com> Date: Wed, 21 Feb 2024 20:49:46 +0530 Subject: [PATCH] Update script.js --- Calculators/Percentage-Calculator/script.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Calculators/Percentage-Calculator/script.js b/Calculators/Percentage-Calculator/script.js index 764b931af..0b4cf74c3 100644 --- a/Calculators/Percentage-Calculator/script.js +++ b/Calculators/Percentage-Calculator/script.js @@ -7,6 +7,7 @@ function calculatePercentage() { alert("Please enter valid numbers"); return; } + var result = (number * percentage) / 100; @@ -17,6 +18,7 @@ function calculatePercentage() { document.getElementById( "result" ).innerText = `Result: ${percentage}% of ${number} is ${result}`; + } // Add a reset function to clear input fields and result @@ -27,5 +29,6 @@ function resetCalculator() { document.getElementById("result").innerText = ""; } + // Add an event listener to the reset button document.getElementById("reset").addEventListener("click", resetCalculator);