Alright so I put this together,
var ms = 0;
var currentCrashNumber = 100;
var nextIncrease = 1.25;
var userIncrease = 1.25;
var multiplierInterval = setInterval(function(){
currentCrashNumber=currentCrashNumber + 10/(3.5/(nextIncrease - nextIncrease/1.25))/1000;
console.log(currentCrashNumber);
ms=ms+10;
if(currentCrashNumber >= nextIncrease){
console.log(ms);
nextIncrease = nextIncrease*(userIncrease);
}
if(currentCrashNumber >= 305){
console.log('Script done in ' + ms + 'ms');
clearInterval(multiplierInterval);
}
}, 10);
This piece of code is to be done in 17500ms or 17.5s. When I launch the code it will eventually result in about 17500ms.
But, when I time it using my stopwatch I end up to over 19000ms or 19.0s, why is this, how can I solve this?
Fiddle: https://jsfiddle.net/2wbbprfj/
I'm having a progress bar on my site, and this is some backend coding but when the progress bar that lasts 17.5s reaches the end the script isn't done yet, which is weird because they are both programmed to end at 17500ms