if I have a string e.g. var myStr="AAAAAAA BBBBB CCCCC DDDDD...", this string can have various length contain words with spaces.
I would like to have a function which will sperate the string into an array, that’s the string will be cut to segements as elements in the array,
where each element of the array contain the words from the string with total length(including space between words) less tha 10 characters long.
(Each element of array always contain complete words & space between words, not cut word from the middle)
I tried:
var words=myStr.split(' ');
then…. what is the efficient way to implement?
Once you have the words, you can iterate over words and push each word into a new array as follows:
EDIT #2