-
-
Notifications
You must be signed in to change notification settings - Fork 133
/
Copy pathindex.js
28 lines (21 loc) · 931 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function calculate(){
const formid = document.getElementById('Form');
const principal = formid['princi'].value;
const rate = formid['rate'].value;
const tenure = formid['tenure'].value;
const principal_float = parseFloat(principal);
const rate_float = parseFloat(rate); //rate in %
const tenure_int = parseInt(tenure); // tenure in months , eg: 2 yrs=> 240 months
const rate_month = rate_float/ (12 * 100); //rate per moth => if rate is 10%, rate per month = 10/12 = 0.833%
var nr = 1;
for(var i=1; i<=tenure_int; i++)
nr*=(1+rate_month);
//alert(nr);
var res = (principal * rate_month * nr)/(nr - 1);
res_final = res.toFixed(2);
//alert(res);
/*const interest = principal_float * rate_float * tenure_float / 100 ;
const amt = interest + principal_float;
const res = amt / tenure_float;*/
document.getElementById('res').innerHTML = res_final;
}