Automatic calculations using JavaScript

Hello everyone
Am working on an investment kind of website. I need help with a JavaScript code that can calculate a certain percentage of the amount someone invested every 48 hours.

Example: Someone deposited $100
I need an automatic crediting of 5% of the amount deposited every 48 hours.

Any help is highly appreciated.

var intervalID = window.setInterval(CreditAccount, 17,280,000);

var stake_percent= 0.05;

var deposit;

var stake_dollars;

function CreditAccount() {

stake = stake + deposit*stake_percent;


1 Like

Okay sir
Lemme test it and give feedback

Ok sir
This code works but am encountering another challenge.
Can you help me with a code that will enable me to pull time data out of the database so the automatic crediting will work with that time?

After users make deposit, they will use the money to buy a package. I’ve set a timer for every package the user buys. So the moment the user buys the package, a 30 day timer starts. Every package expires after 30 days. I want to pull the data out of that timer. So in every 48 hours of that timer, the automatic crediting also credits the person’s account balance.
I can’t seem to pull the timer to work with the auto calculation.