Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript code to calculate compound interest

A self invoking function that can calculate compound interests

(function calc(){
  // p is principal amount
  let p=100000;
  // t is time
  let t=16;
  // r is interest rate
  let r=7.6
  // x is the final interest 
  let x=p;
  for(let i=1;i<t;i++){
    if(i==1){
      x*=(1+r/100);
    }
    x=(p+x)*(1+r/100);
  }
  console.log(x)
})()
 
PREVIOUS NEXT
Tagged: #javascript #code #calculate #compound #interest
ADD COMMENT
Topic
Name
7+4 =