1
var checkMove = function (board, rMove, cMove, color) {2
const moves = [-1, 0, 1];6
for (let i = 0; i < 3; ++i) {7
for (let j = 0; j < 3; ++j) {8
if (i === 1 && j === 1) continue;10
const rowDir = moves[i];11
const colDir = moves[j];13
if (isLegal(rMove, cMove, rowDir, colDir, color, 1)) return true;19
function withinBound(row, col) {20
return row >= 0 && col >= 0 && row < 8 && col < 8;23
function isLegal(currRow, currCol, rowDir, colDir, startColor, length) {24
if (!withinBound(currRow, currCol)) return false; // we went passed the boundaries25
if (board[currRow][currCol] === startColor) return length >= 3; // we seen another start color26
if (board[currRow][currCol] === "." && length > 1) return false;