Split String Into Substrings Javascript Interview