* @param {string} character * @return {TrieNode}
(character)
| 42 | * @return {TrieNode} |
| 43 | */ |
| 44 | removeChild(character) { |
| 45 | const childNode = this.getChild(character); |
| 46 | |
| 47 | // Delete childNode only if: |
| 48 | // - childNode has NO children, |
| 49 | // - childNode.isCompleteWord === false. |
| 50 | if ( |
| 51 | childNode |
| 52 | && !childNode.isCompleteWord |
| 53 | && !childNode.hasChildren() |
| 54 | ) { |
| 55 | this.children.delete(character); |
| 56 | } |
| 57 | |
| 58 | return this; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * @param {string} character |
no test coverage detected