I was in need of a function that repeated it self at a random interval between a certain range of seconds.
I found this one what does what i needed. javascript setinterval with random time
function myFunction() {
var min = 5,
max = 10;
//Generate Random number between 5 - 10
var rand = Math.floor(Math.random() * (max - min + 1) + min);
alert('Wait for ' + rand + ' seconds');
setTimeout(myFunction, rand * 1000);
}
myFunction()
Problem that i'm having now is how to break in to this function to stop/start it?