count duplicate words in string javascript