I am new to coding. I am doing some HTML work and today got into JavaScript. I have tried by myself fixing this and trying to get it done by researching many things and watching videos but I still can't get it right.
So what I am trying to do here is a simple calculator of financial returns, I have a constant of 33% return and I am trying that the person can input his desired amount to invest and calculate how much money he will get in return. The simple Excel math is:
( 15000 / 33% ) = 45,454
I realized that I cant use percentages in JavaScript so I decided to create a constant which eventually will give me 33% (8.25/25)
HTML code:
<div class="col-xl-6 mt-md-30 mt-xs-30 mt-sm-30">
<div class="card">
<div class="card-body">
<h4 class="header-title">Calculate Earnings</h4>
<div class="exhcange-rate mt-5">
<form action="#">
<div class="input-form">
<input type="text" placeholder="15,000" value="" id="amount" />
<span>USD</span>
</div>
<div class="exchange-devider">In 2025:</div>
<div class="input-form">
<input
type="text"
placeholder="45,454"
value=""
class="showamount"
/>
<span>USD</span>
</div>
<div class="exchange-btn">
<button class="calculateNow" type="calculateNow">
Calculate Now
</button>
</div>
</form>
</div>
</div>
</div>
</div>
javascript code:
<script type="text/javascript">
const percent = 8.25 / 25;
var inputAmount = document.getElementById("amount").value;
function calculate(event) {
document.getElementById("showamount") = inputAmount / percent;
}
exchange - btn.addEventListener("click", calculate);
</script>