Created
January 14, 2023 18:21
-
-
Save deleteman/a8b2b8fdfb3a63d0aef90e264e9d82c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function search(tree, word) { | |
let root = null | |
do{ | |
root = Object.keys(tree).find( k => word.indexOf(k) == 0) | |
word = word.replace(root, "") | |
tree = tree[root] | |
} while(root) | |
return (word == "") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment