function isGameOver(grid, cell, turn) {
  // each direction starts out with one disc (the last placed disc)
  const discCountsByDirection = {
    diagonalDown: 1,
    diagonalUp: 1,
    horizontal: 1,
    vertical: 1
  };

  // tally up the adjacent cells that have discs belonging to the player
  for (let i = 0; i < DIRECTIONS.length; i++) {
    if (checkDirectionForWinner(grid, cell, turn, DIRECTIONS[i], discCountsByDirection)) {
      return true;
    }
  }

  return false;
}
/**
 * Check if any connected discs satisfy the winning condition.
 *
 * Starting with the last placed disc, search outwards until either a winning set is found
 * or there are no more paths to search.
 *
 * @param grid
 * @param cell
 * @param turn
 */
Check if any connected discs satisfy the winning condition.
Starting with the last placed disc, search outwards until either a winning set is found
or there are no more paths to search.


Check if any connected discs satisfy the winning condition . Starting with the last placed disc search outwards until either a winning set is found or there are no more paths to search .
function isGameOver(grid, cell, turn) {
  const discCountsByDirection = {
    diagonalDown: 1,
    diagonalUp: 1,
    horizontal: 1,
    vertical: 1
  };
  for (let i = 0; i < DIRECTIONS.length; i++) {
    if (checkDirectionForWinner(grid, cell, turn, DIRECTIONS[i], discCountsByDirection)) {
      return true;
    }
  }
  return false;
}
function isGameOver ( grid , cell , turn ) { const discCountsByDirection = { diagonalDown : 1 , diagonalUp : 1 , horizontal : 1 , vertical : 1 } ; for ( let i = 0 ; i < DIRECTIONS . length ; i ++ ) { if ( checkDirectionForWinner ( grid , cell , turn , DIRECTIONS [ i ] , discCountsByDirection ) ) { return true ; } } return false ; }
Check if any connected discs satisfy the winning condition.
Check if any connected discs satisfy the winning condition .
// each direction starts out with one disc (the last placed disc) // tally up the adjacent cells that have discs belonging to the player