Using a Trie Data Structure in JavaScript