JavaScript Clean Trie Solution
javascript\nclass Node {\n    constructor() {\n        this.children = new Map();\n        this.end = false;\n    }\n}\n\nclass WordDictionary {\n    constructo
```javascript\nclass Node {\n    constructor() {\n        this.children = new Map();\n        this.end = false;\n    }\n}\n\nclass WordDictionary {\n    constructor() {\n        this.root = new Node();\n    }\n    \n    addWord(word) {\n        function add(node, i) {\n            if(i === word.length) return node.end = true;\n            if(!node.children.has(word[i])) node.children.set(word[i], new Node());\n            add(node.children.get(word[i]), i+1);\n        }\n        add(this.root, 0);\n    }\n    \n    search(word) {\n        function find(node, i) {\n            if(i === word.length && node.end) return true;\n            if(i === word.length) return false;\n            \n            if(word[i] === \'.\') {\n                for(let [key, next] of node.children) {\n                    if(find(next, i+1)) return true;\n                }\n                return false;\n            }\n            if(!node.children.has(word[i])) return false;\n            return find(node.children.get(word[i]), i+1);\n        }\n        return find(this.root, 0);\n    }\n}\n```
['JavaScript']