I'm creating a minesweeper game and by wishing to reveal buttons around blank button, I've got into a problem. I have the following function:
function l_click(event, coordinate_i = event.target.i, coordinate_j = event.target.j)
{
if(block[coordinate_i][coordinate_j].isBomb === true)
{
// lots of irrelevant cocde
}
else {
block[coordinate_i][coordinate_j].src = "blank.png";
for (var i = coordinate_i - 1; i < coordinate_i + 2; i++) {
for (var j = coordinate_j - 1; j < coordinate_j + 2; j++) {
if (coordinate_i < 9 && coordinate_j < 9 && !(block[i][j].isBomb) && !(coordinate_i === i && coordinate_j === j) && block[i][j].src ==="empty-block.png") {
if (block[i][j].nearBombsNum === 0) {
l_click(event, i, j)
}
else {
block[i][j].src = block[i][j].nearBombsNum + ".png";
}
}
}
}
}
}
What I try to do here is to turn images to blank by the buttons of the board. The result I wish for is a recursion in which function is being called 8 times from father function's nested loop (a call for each button around the original button, that will work the same as the original and call the buttons around itself). The result I get is that the first call stop or continues the recursion, but after the first call produced, the loop won't keep going.
I want the father function call to continue the loop run, and to keep on calling for itself by continuing the loop's iteration.
The current situation is that once the button "falls" into the first 'if' statement, the loop from the father function doesn't continue.
(coordinate_i === i && coordinate_j === j) != trueneed parenthesis around it?