// liczenie zywych sąsiadów
function countLiveNeighbors(row, col) {
let count = 0;
for(let i = row – 1; i <= row + 1; i++) {
if (i >= 0 && i < rows){
for(let j = col – 1; j <= col + 1; j++) {
if (j >= 0 && j < columns){
if (i != row || j != col) {
count += grid[i][j].classList.contains(„alive”) ? 1 : 0;
}
}
}
}
}
return count;
}