'cut string after certain number of words javascript [duplicate]
I want to cut this paragraph after certain number of words, not characters
const Text = "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you"
For instance: if i do
Text.substring(0,50)
the output will be
'But I must explain to you how all this mistaken id'
the word "idea" is cut and is not what I want, i want the whole word and then maybe add " . . . "
example 'But I must explain to you how all this mistaken idea . . .'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
