Event that triggers at random time intervals | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Event that triggers at random time intervals

How do I create an event that triggers at random time intervals with JavaScript?

1st Sep 2020, 9:58 AM
Unrealistic Engineer
Unrealistic Engineer - avatar
2 Answers
+ 2
let a=Math.floor(Math.random()*500); setTimeout(print,a) function print(){ a=Math.floor(Math.random()*7000); document.body.innerHTML=""+a; setTimeout(print,a); };
1st Sep 2020, 10:10 AM
Abhay
Abhay - avatar
+ 1
Thank you!
1st Sep 2020, 10:29 AM
Unrealistic Engineer
Unrealistic Engineer - avatar