Is it possible to have a invertal function that stop and starts if a variable is too high or too low
How can I make moneymaker stop when it reach 300?
I Tried with this code, but didn't get any results...
Code ex.
var money = 0;
var maxmoney = 300;
var moneymaker = window.setInterval(function(){
    money = money + 1;
    document.getElementById('money').innerHTML = money;
    }, 1000);
function stopInter(){
    if(hp >= maxhp)
    clearInterval(regen);
    }else{
    setTimeout(function(){}, 1000); 
    }
}
 
    