Home › Forums › JavaScript › window.setInterval(function() Need help › Reply To: window.setInterval(function() Need help
December 29, 2014 at 7:25 pm
#191845
tarnos12
Participant
Thing is, there is nothing that “start” this interval…it just works on its own.
window.setInterval(function()
{
if (health + hpregen >= maxhealth)
{
health = maxhealth;
document.getElementById('health').innerHTML = health;
}
else if (health + hpregen < maxhealth)
{
health = health + hpregen;
document.getElementById('health').innerHTML = health;
}
}, 1000);
thats all :> there are just global variables.