Skip to content

Instantly share code, notes, and snippets.

@deleteman
Created January 14, 2023 18:21
Show Gist options
  • Save deleteman/a8b2b8fdfb3a63d0aef90e264e9d82c4 to your computer and use it in GitHub Desktop.
Save deleteman/a8b2b8fdfb3a63d0aef90e264e9d82c4 to your computer and use it in GitHub Desktop.
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