set interval Allows to run a function in regular intervals. The second argument takes the interval time in milliseconds. The example checks for the existence of the class before stopping the loop. #javascript#loop var checker = setInterval(function() { if (document.querySelector('.sc')) { console.log('Found it!'); clearInterval(checker); } }, 100); copy