Hey I try to bulid a minesweeper game
so I create the game and I call emptyCell When user click on empty cell (cell box in the game)
now I get this error:
Uncaught RangeError: Maximum call stack size exceeded
So I search and I found this answer Chrome/jQuery Uncaught RangeError: Maximum call stack size exceeded that says:
You can also get this error when you have an infinite loop. Make sure that you don't have any unending, recursive self references.
So I check and realy the functions call to her self over 500 times I dont know why, I have only 100 cells on my page this is the function:
function emptyCell(cell, x, y) {
  cell.className = "show";
  var i, Next, Prev;
  Next = y + 1;
  Prev = Prev + 1;
  for (i = x - 1; i <= x + 1; i++) {
    if (Game[Next] !== undefined && Game[Next][i]) {
      if (Game[Next][i] == 0) emptyCell(GameBoxes[Next][i], i, Next);
      else {
        GameBoxes[Next][i].innerHTML = Game[Next][i];
        GameBoxes[Next][i].className = "show c" + Game[Next][i];
      }
    }
    if (Game[Prev] !== undefined && Game[Next][i]) {
      if (Game[Prev][i] == 0) emptyCell(GameBoxes[Prev][i], i, Prev);
      else {
        GameBoxes[Prev][i].innerHTML = Game[Prev][i];
        GameBoxes[Prev][i].className = "show c" + Game[Prev][i];
      }
    }
  }
  if (Game[y] !== undefined && Game[y][x - 1] !== undefined) {
    if (Game[y][x - 1] == 0) emptyCell(GameBoxes[y][x - 1], x - 1, y);
    else {
      GameBoxes[y][x - 1].innerHTML = Game[y][x - 1];
      GameBoxes[y][x - 1].className = "show c" + Game[y][x - 1];
    }
  }
  if (Game[y] !== undefined && Game[y][x + 1] !== undefined) {
    if (Game[y][x + 1] == 0) emptyCell(GameBoxes[y][x + 1], x + 1, y);
    else {
      GameBoxes[y][x + 1].innerHTML = Game[y][x + 1];
      GameBoxes[y][x + 1].className = "show c" + Game[y][x + 1];
    }
  }
}
 
    