Good day,
I would like to know if there is an easy way to chunk/split a string without breaking the words.
Eg:
var input = \"Lorem ipsum dolo
Thank to orourkedd, it iwas very useful. I just updated it with splitting.
private chunkString(str, len) {
let input = str.trim().split(' ');
let [index, output] = [0, []]
output[index] = '';
input.forEach(word => {
let temp = `${output[index]} ${word}`.trim()
if (temp.length <= len) {
output[index] = temp;
} else {
index++;
output[index] = word;
}
})
return output
}