Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
  • Loading branch information
VIDHISHAK15 authored Feb 21, 2024
1 parent 3a789f0 commit d4df584
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Calculators/Percentage-Calculator/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function calculatePercentage() {
alert("Please enter valid numbers");
return;
}


var result = (number * percentage) / 100;

Expand All @@ -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
Expand All @@ -27,5 +29,6 @@ function resetCalculator() {
document.getElementById("result").innerText = "";
}


// Add an event listener to the reset button
document.getElementById("reset").addEventListener("click", resetCalculator);

0 comments on commit d4df584

Please sign in to comment.