Mi solución:
function verifyWordFromBoard(i, j, word, board, currentWord, matches, visitedSpots) {
if (i < 0 || i >= board.length) return;
if (j < 0 || j >= board[i].length) return;
if (!word.includes(currentWord)) return;
if (word === currentWord) return matches.push(currentWord);
if (visitedSpots.find((spot) => spot.i === i && spot.j === j)) return;
visitedSpots.push({ i, j });
verifyWordFromBoard(i - 1, j, word, board, currentWord + board[i][j], matches, visitedSpots);
verifyWordFromBoard(i, j + 1, word, board, currentWord + board[i][j], matches, visitedSpots);
verifyWordFromBoard(i + 1, j, word, board, currentWord + board[i][j], matches, visitedSpots);
verifyWordFromBoard(i, j - 1, word, board, currentWord + board[i][j], matches, visitedSpots);
}
export function wordExist(board, word) {
let visitedSpots = [];
for (let i = 0; i < board.length; i++) {
const row = board[i];
for (let j = 0; j < row.length; j++) {
const letter = row[j];
let matches = [];
if (letter === word[0]) {
verifyWordFromBoard(i, j, word, board, '', matches, visitedSpots);
}
if (matches.length > 0) return true;
}
}
return false;
}