there is a requirement
to output a paragraph of text to a div every 10 seconds. After 50 cycles, the loop starts from 0 until the close button is clicked to stop the loop.
the following is the code I wrote earlier, but cleartimeout doesn"t work because the for loop activates settimeout again. Is there a good way to do it?
for (let i = 0, len = this.params.playTimes + 1; i < len; iPP) {
this.playText = setTimeout(() => {
this.fillText(i);
var myDate = new Date();
console.log(i,myDate.toLocaleString());
}, i * this.params.speed * 1000);
}
// setTimeoutfor todo
clearTimeout(this.playText);