I have tried to calculate some numbers using javascript for loop. But, couldn't get desired result.

Example, Base quantity is 10000 and percentage is 8.

First 12 months it should be,

> 
> 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000 10000
>  10000
> 
> 
> 

Next 12 months, I have to calculate 8 percent of 10000 and add it to base quantity. 8 percent of 10000 is 800. So, output for next 12 month is,

> 
> 10800 10800 10800 10800 10800 10800 10800 10800 10800 10800 10800
>  10800
> 
> 
> 

Next 12 months, I have to calculate 8 percent of 10800 and add it to previous base quantity. 8 percent of 10800 is 864. So, output for next 12 month is,

> 
> 11664 11664 11664 11664 11664 11664 11664 11664 11664 11664 11664
>  11664
> 
> 
> 

Next 12 months, I have to calculate 8 percent of 11664 and add it to previous base quantity. 8 percent of 11664 is 933.12. So, output for next 12 month is,

> 
> 12597.12 12597.12 12597.12 12597.12 12597.12 12597.12 12597.12 12597.12 12597.12 12597.12 12597.12 12597.12
> 
> 
> 

Tried below code so far,

**Javascript**

```
function myFunction() {
    l = 12;
    a = document.getElementById("base").value;
    hk = (a*document.getElementById("per").value)/100;

    for (var i = 0; i < l; i++) {
      if(i % 12 === 0) {
          a = Number(document.getElementById("base").value) + Number(hk);
      }
    }
         document.getElementById("demo").innerHTML += a;

  }

```

**HTML**

```
<div>
    <span>Base</span>
    <input type="text" id="base" value="10000" />
  </div>
  <div>
    <span>Percentage</span>
    <input type="text" id="per" value="8" />
  </div>

  <button onclick="myFunction()">Click</button>

  <p id="demo"></p>

```

**[JsFiddle](https://jsfiddle.net/xkf9ocme/)**