I want to pause but still run other code at the same time. For example:
while (true) {
unit++
// wait 3 seconds
}
// do this at the same time
while (true) {
something += 25
// wait 5 seconds
}
I want to pause but still run other code at the same time. For example:
while (true) {
unit++
// wait 3 seconds
}
// do this at the same time
while (true) {
something += 25
// wait 5 seconds
}
This will increase unit by 1 every three seconds and something by 25 every five seconds. The time units are in milliseconds so divide by 1000 to get the time in seconds and vice versa.
setInterval(function() {
unit++;
}, 3000);
setInterval(function() {
something += 25;
}, 5000);