Implementing a trie in JavaScript, just for fun