Ciao, è possibile fare in modo che al verificarsi di un certo numero di volte di un boolean, mi avvii un evento?
Ad esempio ho questo ciclo:

codice:
var table = document.getElementById("table");
	var numRows = table.rows.length;
       for (var i=numRows-1; i > 0; i--){
	    if(i==6) {
		var numCells = table.rows[i].cells.length;
		for (var j=0; j<numCells; j++){
		   var cellsCount = table.rows[i].cells[j];
		   var imgCells = cellsCount.innerHTML;
		   //alert(cellsCount);
		   var verImgRed = imgCells.indexOf("cerchio_red") > -1; 
		   var verImgBlack = imgCells.indexOf("cerchio_black") > -1;
		    alert("works");
		    }
Voglio fare in modo che se verImgRed è uguale a true per 4 volte consecutivamente, mi visualizzi un alert o qualsiasi altra cosa.
Suggerimenti? :master: