Limit text to specified number of words using Javascript 1

Limit text to specified number of words using Javascript

"Want better search results? See our search tips".split(" ").splice(0,3).join(" ")

Here is what the above code is Doing:
1. We’re splitting the string into an array of words.
2. We’re splicing the array to get the first three words.
3. We’re joining the array back into a string.

Similar Posts