From 57b63aeb9c92ff9f46349fdd1159109317fe3785 Mon Sep 17 00:00:00 2001 From: Dharshnilingam Date: Sun, 13 Oct 2024 09:17:05 +0530 Subject: [PATCH] Update script.js --- script.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/script.js b/script.js index 7adfb78be..c6aa5a4df 100644 --- a/script.js +++ b/script.js @@ -1,6 +1,11 @@ -function compute() -{ - p = document.getElementById("principal").value; - +function compute() { + const principal = document.getElementById("principal").value; + const rate = document.getElementById("rate").value; + const years = document.getElementById("years").value; + + // Calculate interest + const interest = (principal * rate * years) / 100; + + // Display the result + document.getElementById("result").textContent = interest; } - \ No newline at end of file