var grid = [];
for (var i = 0;i < 6;i++)
{
for (var j = 0; j < 6; j++)
grid[i] = [];
}
//Function to determine the number of bombs nearby
function check(cx,cy)
{
var numb = 0;
if (grid[cx][cy - 1] == "B") numb++;
if (grid[cx][cy + 1] == "B") numb++;
if (grid[cx - 1][cy] == "B") numb++;
if (grid[cx + 1][cy] == "B") numb++;
if (grid[cx - 1][cy - 1] == "B") numb++;
if (grid[cx + 1][cy - 1] == "B") numb++;
if (grid[cx - 1][cy + 1] == "B") numb++;
if (grid[cx + 1][cy + 1] == "B") numb++;
return numb;
}**
I encountered an error while checking positions with cx +/- 1. I attempted different methods to create the array but was unsuccessful. My goal is to develop a minesweeper game, hence why I am trying to determine how many bombs are near each given index.