How to stop setTimeout? in a for loop

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);
Apr.07,2021

if you want to trigger every 10 seconds and terminate after 50 times, why not use setInterval?

var count = 1;
var fixTextInterval = setInterval(function() {
        dosomething();
        countPP;
        if(count > 50) count = 1;
   }, speed*1000);

btnStop.click(function() {
    clearInterval(fixTextInterval);
});
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3b761-40821.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3b761-40821.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?