Good evening! There was a problem with the solution of the problem. There are 9 blocks (an array of mult from 0 to 8). Task: to cyclically change the background of each block after a certain time interval. To change the background color there is a function colorChange (i, color). To her no complaints. The problem is that the background changes only during the first passage through the blocks from 0 to 8. Then, when the counter returns to its original value of 0, to walk through all the blocks again, the background color does not change anymore. Below is my code.
var mult = document.getElementsByClassName('mult'); function colorChange(i, color) { mult[i].classList.add(color); } var i = 0; var timerId = setInterval(function() { if (i != 0) { colorChange(i-1, 'white'); } if (i === 9) { i = 0; } colorChange(i, 'yellow'); i++; }, 300);