Share my JavaScript solution
\nvar TrieNode = function() {\n    this.children = {};\n    this.isEnd = false;\n};\n\n/**\n * Initialize your data structure here.\n */\nvar WordDictionary = f
```\nvar TrieNode = function() {\n    this.children = {};\n    this.isEnd = false;\n};\n\n/**\n * Initialize your data structure here.\n */\nvar WordDictionary = function() {\n    this.root = new TrieNode();\n};\n\n/**\n * Adds a word into the data structure. \n * @param {string} word\n * @return {void}\n */\nWordDictionary.prototype.addWord = function(word) {\n    var current = this.root;\n    \n    for (let i = 0; i < word.length; i++) {\n        if (!(word[i] in current.children)) {\n            current.children[word[i]] = new TrieNode();\n        }\n        current = current.children[word[i]];\n    }\n    \n    current.isEnd = true;\n};\n\n/**\n * Returns if the word is in the data structure. A word could contain the dot character '.' to represent any one letter. \n * @param {string} word\n * @return {boolean}\n */\nWordDictionary.prototype.search = function(word) {\n    var search = function(current, level) {\n        // Cannot search for the word\n        if (!current || (level === word.length && !current.isEnd)) {\n            return false;\n        }\n        \n        if (level === word.length && current.isEnd) {\n            return true;\n        }\n        \n        if (word[level] === '.') {\n            for (let i = 0; i < 26; i++) {\n                var ch = String.fromCharCode(97 + i);\n                \n                if (search(current.children[ch], level + 1)) {\n                    return true;\n                }\n            }\n            \n            return false;\n        }\n        \n        return search(current.children[word[level]], level + 1);\n    };\n    \n    return search(this.root, 0);\n};\n\n/** \n * Your WordDictionary object will be instantiated and called as such:\n * var obj = Object.create(WordDictionary).createNew()\n * obj.addWord(word)\n * var param_2 = obj.search(word)\n */\n```
[]