MCPcopy Index your code
hub / github.com/trekhleb/javascript-algorithms / addWord

Method addWord

src/data-structures/trie/Trie.js:15–25  ·  view source on GitHub ↗

* @param {string} word * @return {Trie}

(word)

Source from the content-addressed store, hash-verified

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

Callers 1

Trie.test.jsFile · 0.80

Calls 1

addChildMethod · 0.45

Tested by

no test coverage detected