longestWord javascript function with regular expression