How can i find the ETA of an event in javascript using simple variables
I am developing a javascript game and would like to display an ETA telling
the user how long they have left until they lose the game. This figure is
dependent on 3 variables,
var max = 1000000 /* 1 million */
var current = 50 /* 50 currently */
var persec = 10 /* 10 new ones created every second */
How using javascript can I calculate an estimate of the number of seconds
till current >= max using the rate of change provided using persec?
Things I have tried
var eta = (max - current / persec) / 60;
eta = Math.round(eta);
but this did not work as I am expecting it to.
No comments:
Post a Comment