Hello!
Please help me with an opinion:
This task seems to work ok for me, I tested it with online compilers, everything OK.
But I'm stuck with "3. The result should include only the full words".
Here is the code:
export const shortenByWords = (s, n) => {
let outStr=s;
let m=0;
let final = "";
let splitStr=s.split(" ");//s string to splitStr array
let splitStrInit=s.split(" ");// initial array
if(s.length<=n)
{
outStr=s;
}else
{ m=n-1;
//if (s[m]===" "){final=" ";}
while(n<outStr.length)
{
for(let i =0; i<splitStr.length;i++)
{
splitStr=splitStr.slice(0,-1);
outStr=splitStr.join(" ");
}
}
outStr=outStr+final+"..."
}
return(outStr);
}
Please!!!!!!!!