Why does it go on indefinitely? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why does it go on indefinitely?

Building a random generator that would generate four numbers on clicking the button but it doesn't stop at four using Jscript. Don't run it! You may have to force close your app. What can I do to stop it at the 4th time? https://code.sololearn.com/W7W6rDYwYdLG/?ref=app

20th Nov 2019, 1:57 PM
Miracle Ufodiama
2 Answers
+ 4
Your click event is useless because you cancel it before it has time to take effect. Your setInterval call sets an interval to repeat indefinitely until you cancel it.
21st Nov 2019, 2:55 AM
John Wells
John Wells - avatar
+ 4
This disables button clicking, while waiting for the four alerts. https://code.sololearn.com/WVnack4Y7D1u
21st Nov 2019, 3:12 AM
John Wells
John Wells - avatar