My script is to calculate a pension via putting in a fixed amount from the day you start employment until the last day based upon pension age, so my DOB is 25/12/1991 therefore if I retire at pension age of 68, it'll be on 25/12/2060.
function hello(){ var i; var t = 50; var f = 0; for (i = 0; i < CalcY; i++) { f = ((t*52) + f) * 1.08; $('#collection').append("<li>Year: " + i + " Amount: £" + (f).toFixed(2).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") + "</li>"); } TotalPension = ((t*CalcW) + f); $('#collection').append("<li>END Amount: £" + (TotalPension).toFixed(2).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") + "</li><br /><br /><br />"); if (i < CalcY) window.setTimeout(hello, 0); hello2(); }
The first part runs through listing how much it'll be at the end of each year with an 8% interest rate gain and then hello2();
is to calculate taking out money each year with interest gained on the remaining.
So hello2();
I need to stop once the investment drops below money taken out each year which seems to be working partly but doesn't stop, it just keeps repeating as if it was calling itself.