Got some problems with floodfill, i don't rly understand what is wrong with it as I tried to copy some code from someone other code, it was working for him, for me not. I have got a 9x9 double dimension array as border. First i wanted to display only fields horizontally, but the code goes infinity. With one FloodFill on it works good.
function floodFill(x, y) {
if (y < 0) {
console.log("left border exceeded");
return;
}
if (y > 8) {
console.log("right border exceeded");
return;
}
if (numberOfBombsAdjacentToField[x][y] > 0) {
console.log("there are bombs nearly");
return;
}
if (document.getElementById(((x).toString() + (y).toString())).style.backgroundColor == "darkGray") {
console.log("already clicked");
return;
}
document.getElementById(((x).toString() + (y).toString())).style.backgroundColor = "darkGray";
floodFill(x, y + 1);
floodFill(x, y - 1);
}