Ok so I'm making an idle game, and so that you don't have to wait every second to get ozolith(the currency in the game), I made a variable called ops(ozolith per second) and did a setInterval() run in a way that if the person has 2 ops, it would run every .5 seconds. This works most times but sometimes it goes nuts and decides it goes as fast as if the player had 1000 ops so it runs every 1 miliseconds. Here's the code that's the source of the problem to help you find an answer to this.
ops = Math.floor(((reactors*10)+mines)*((alientransbought*colplanets)+1))
if(ops>=1){
setInterval(production,Math.floor(1000/ops)) //Production is just where it gives the ozolith and is not
the root of the problem
}