this count
?this.count
if (this.count > 1) {
this.classList.add('off');
this.classList.remove('on');
sum -= num;
}
count
- общее кол-во кликовfor (let i = 0; i < blocks.length; i++) {
blocks[i]._clickCnt = 0;
blocks[i].addEventListener('click', function() {
var num = parseFloat(blocks[i].innerText, 10);
if (this._clickCnt > 1) {
this.classList.add('off');
this.classList.remove('on');
sum -= num;
this._clickCnt--;
} else {
this.classList.add('on');
this.classList.remove('off');
sum += num;
this._clickCnt++;
}
blockResult.innerHTML = sum;
});