Javascript 扫雷舰:回收瓦片附近地雷的问题

Javascript 扫雷舰:回收瓦片附近地雷的问题,javascript,minesweeper,uncaught-exception,Javascript,Minesweeper,Uncaught Exception,我有这个问题。我的功能似乎是检查10x10板的外部边界。它用于返回瓷砖周围的地雷数量[行,列],但我得到: mineswipper.js:152未捕获类型错误:无法读取未定义的属性“0” 在getAdjacentMines(扫雷舰js:152) 这是我的功能,谢谢大家抽出时间 函数getAdjacentMines(行、列){ 让计数=0; 设minRow=row-1; 设maxRow=row+1; 设minCol=col-1; 设maxCol=col+1; 如果(minRowboard.len

我有这个问题。我的功能似乎是检查10x10板的外部边界。它用于返回瓷砖周围的地雷数量[行,列],但我得到:

mineswipper.js:152未捕获类型错误:无法读取未定义的属性“0”
在getAdjacentMines(扫雷舰js:152)
这是我的功能,谢谢大家抽出时间

函数getAdjacentMines(行、列){
让计数=0;
设minRow=row-1;
设maxRow=row+1;
设minCol=col-1;
设maxCol=col+1;
如果(minRow<0)minRow=0;
如果(maxRow>board.length)maxRow=board.length-1;
如果(minCol<0)minCol=0;
如果(maxCol>board.length)maxCol=board.length-1;

对于(row=minRow;row欢迎使用堆栈溢出

你似乎在这一部分有一个打字错误

for (row = minRow; row <= maxRow; row++) {
    for (col = minCol; col <= maxCol; row++) {
        if (board[row][col].boom === true) count++;
    }
}
for(row=minRow;row
//                                 v here
for (col = minCol; col <= maxCol; col++) {
 for (col = minCol; col <= maxCol; row++) {