Right now i have a text-based game that deals with turns, but i want to upgrade it to a timer system so that when the timer hits 0 then you gain 1 or 2 of whatever action you were doing. Also if you know how to make it randomly pick whether u get 1 item or 2 items could you please elaborate on how to do that? Thank you to all responses.
You can use setTimeout()
for delaying actions for a set period of time, or setInterval()
if you wish to run it periodically on a given interval.
For getting a random number either 1 or 2 you can use random()
:
var randomOneOrTwo = Math.floor(Math.random() * 2) + 1;