* @param {string} word * @return {Trie}
(word)
| 13 | * @return {Trie} |
| 14 | */ |
| 15 | addWord(word) { |
| 16 | const characters = Array.from(word); |
| 17 | let currentNode = this.head; |
| 18 | |
| 19 | for (let charIndex = 0; charIndex < characters.length; charIndex += 1) { |
| 20 | const isComplete = charIndex === characters.length - 1; |
| 21 | currentNode = currentNode.addChild(characters[charIndex], isComplete); |
| 22 | } |
| 23 | |
| 24 | return this; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * @param {string} word |