I'm coding a game that has a 2 minute timer countdown - within that time i want an alert to popup randomly in multiples of 10 seconds. The alert could be called at 10 seconds, 30 seconds or even 110 seconds - as long as they are in multiples of 10.
(function loop() {
var rand = Math.round(Math.random() * (60000 - 10000)) + 10000;
setTimeout(function() {
alert("hi");
loop();
}, rand);
}());
I've found some code whilst doing some research but I don't think I've quite got it right?
Can anyone help?
Thanks Al