1
var updateBoard = function (board, click) {2
const rows = board.length;3
const cols = board[0].length;4
dfs(click[0], click[1]);8
if (!board[i][j]) return;9
if (board[i][j] === "M") {13
if (board[i][j] !== "E") return;15
const mines = checkForMine(i, j); // Check for mines18
board[i][j] = mines.toString();21
// If we haven't got mines, check another cells23
for (let x = Math.max(i - 1, 0); x < Math.min(i + 2, rows); x++) {24
for (let y = Math.max(j - 1, 0); y < Math.min(j + 2, cols); y++) {31
function checkForMine(x, y) {33
for (let i = Math.max(x - 1, 0); i < Math.min(x + 2, rows); i++) {34
for (let j = Math.max(y - 1, 0); j < Math.min(y + 2, cols); j++) {35
if (board[i][j] === "M") mines++;