Remove the first argument:
var short_description = description.split(' ').slice(100).join(' ');
Using slice(x, y) will give you elements from x to y , but with slice(x) you will get elements from x to the end of the array. (note: this will return an empty string if the description has less than 100 words.)
Here is some documentation .
You can also use regex:
var short_description = description.replace(/^([^ ]+ ){100}/, '');
Here is an explanation of the regular expression:
^ beginning of string ( start a group [^ ] any character that is not a space + one or more times then a space ) end the group. now the group contains a word and a space. {100} 100 times
Then replace these 100 words with nothing. (note: if the description is less than 100 words, this regular expression will simply return the description unchanged.)
source share