I created a function that does this job, however, I advise you to test and optimize it before applying in a real case, even more when the string is too large. I would do this on the server-side and send the processed string to the client-side.
Behold:
function dividirStrPor(str, caractereDivisao, pedacos)
{
var tam = str.length;
for (var i = 0; i < pedacos; i++)
{
posicao = Math.floor(Math.random() * (tam - 0 + 1) + 0);
str = str.slice(0, posicao) + caractereDivisao + str.slice(posicao);
}
return str;
}
var str = "Deliciosogostoeobomgostodasnuvensseremfeitasdealgodao";
var resultado = dividirStrPor(str, " ", 12);
console.log(resultado);
Exit:
D e lic iosogos t oeob omgostodas nuvensseremfe i t asdealgodao
The output changes at each function call due to the random position at which the split character will be inserted into the string.
See working on repl it..
Sources:
Javascript: How can I Insert a string at a specific index
Generate Random number between two Numbers in Javascript
Ever tried to do something? If so, enter the code, explain it, and describe the problems encountered.
– Woss
I found a code and changed it but it does not separate right, always missing some letter
var str = 'Deliciosogostoeobomgostodasnuvensseremfeitasdealgodao';
var chunks = [];

for (var i = 0, charsLength = str.length; i < charsLength; i += (Math.floor(Math.random()*10)+1)) {
 chunks.push(str.substring(i, i + (Math.floor(Math.random()*10)+1)));
}
console.log(chunks.toString().replace(/\,/g," "));
– Jefter Rocha