I have an if statement which looks something like this:
if( extra.RewardId === "idnumberhere") {
egg.classList.add("bounce");
setTimeout (() => {
egg.classList.remove("bounce");
petEffects.innerText = `Working`;
petEffects.classList.add("typing");
}, 3000);
setTimeout (() => {
petEffects.innerText = ``;
petEffects.classList.remove("typing");
}, 5000);
}
It is a bit longer than this, but the main problem is that it is interrupting itself if I trigger the if statement a second time, too soon.
How would go about making the second instance wait until the first if statement fully runs its course, and those 5000ms pass before the next instance begins?
Aucun commentaire:
Enregistrer un commentaire