Спасибо, не могли бы помочь теерь с таймером?
Чего-то не работает он
<!doctype html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<link href="css/style.css" rel="stylesheet">
<title>Document</title>
</head>
<body>
<div id="time">0.000</div>
<script>
var mili = 0.0;
var time = document.getElementById("time");
function plusMil() {
mili += 0.01;
time.innerHTML = Math.floor(mili * 100) / 100;
}
let interval
class gameTable {
constructor(arr, colls, rows) {
this.colls = colls;
this.rows = rows;
this.length = this.colls * this.rows;
this.index = 0;
this.array = arr;
this.contentTd = this.createContent(this.array, this.length);
this.table = document.createElement('table');
this.createTableHtml();
this.table.addEventListener("click", this.clickHandler.bind(this));
}
shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
let j = Math.trunc(Math.random() * i);
[array[i], array[j]] = [array[j], array[i]];
}
return array;
}
createContent(array, length) {
let content = [];
for (let i = 0; i < array.length;) {
let temp = array.slice(i, i += length);
temp = this.shuffleArray(temp);
content = content.concat(temp);
}
return content
}
createTableHtml() {
this.index = 0;
for (var i = 0; i < this.rows; i++) {
let row = this.table.insertRow();
for (var k = 0; k < this.colls; k++) {
let cell = row.insertCell();
cell.textContent = this.contentTd[this.index++] || '';
}
}
this.index = 0;
}
clickHandler({target}) {
target = target.closest('td');
if (!target) return;
let txt = target.textContent;
if (txt == this.array[this.index]) {
txt = this.contentTd[this.index + this.length] || '';
target.textContent = txt;
target.classList.toggle('collapsing', !txt);
this.index++;
if (+td.textContent == 'А'){
interval=setInterval(plusMil, 10);
}
if (+td.textContent == 'Я'){
clearInterval(interval)
}
}
}
}
let game = new gameTable('АБВГДЕЁЖЗИЙКЛМНОП'.split(''), 3, 4);
document.body.appendChild(game.table);
</script>
</body>
</html>