0
function myFunc() {
    console.log('myFunc called');
    if (1 == 2) {
        //When the condition fulfilled clear the setTimeout.
    } else {
        setTimeout(myFunc, 1000);

        // I want to clear the timeout after 10 seconds
    }
};

Now myFunc running infinitely.

If the condition didn't match within 10 seconds i want to clear the setTimeout to stop the myFunc call and reload the page using window.location.reload()

If the condition fulfilled clear the setTimeout.

Thanks

Shimul D
  • 403
  • 4
  • 9

0 Answers0