Truncate a string on a word break with Javascript