🥪JavaScript Recursive Solution w/ Explanation
The idea\nSince it\'s obvious that there will be a lot of repetitive work, such as checking up, down, left, right for lots of characters, we can use recusion to
#### The idea\nSince it\'s obvious that there will be a lot of repetitive work, such as checking up, down, left, right for lots of characters, we can use recusion to simplify our code. \nOur base case will need to check:\n1. are we getting out of boundary? if yes, get out.\n2. are we getting a wrong character? If yes, get out.\n3. did we find every character from the work? If yes, great, we have found this word.\nOtherwise keep exploring characters for all directions.\n\n``` javascript\n/**\n * @param {character[][]} board\n * @param {string} word\n * @return {boolean}\n */\nvar exist = function(board, word) {\n    let result = false;\n    var check = function(r, c, i) {\n        if (!result) {\n            if (r < 0 || c < 0 || r >= board.length || c >= board[0].length) return; // out of boundary\n            if (board[r][c] != word[i]) return; // wrong character\n            if (i == word.length - 1) { // got to the end means we found a correct path\n                result = true;\n                return;\n            }\n            board[r][c] = null; // mark our path so we dont go back and forth\n\t\t\t// try all directions\n            check(r+1,c,i+1)\n            check(r-1,c,i+1)\n            check(r,c+1,i+1)\n            check(r,c-1,i+1)\n            board[r][c] = word[i] // reset our board , very important\n        }\n    }\n\n    for (let i=0;i<board.length;i++) {\n        for (let j=0;j<board[0].length;j++) {\n            if (board[i][j] == word[0]) {\n                check(i, j, 0)\n                if (result) return result;\n            }\n        }\n    }\n    \n    return result;\n};\n```
['JavaScript']