refactoring bob, anagram, and word-count for js