Answer the question
In order to leave comments, you need to log in
Why do we reset the code in the first one, but not in the second one, and why in the second code there are values of 100 twice, what is their essence?
function printNumbersInterval() {
var i = 1;
var timerId = setInterval(function() {
console.log(i);
if (i == 20) clearInterval(timerId);
i++;
}, 100);
}
// вызов
printNumbersInterval();
function printNumbersTimeout20_100() {
var i = 1;
var timerId = setTimeout(function go() {
console.log(i);
if (i < 20) setTimeout(go, 100);
i++;
}, 100);
}
// вызов
printNumbersTimeout20_100()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question