function shortener(str) {
const regex = /\s+(\S*)$/g;
if(str.length <= 160){
return str;
};
let match = str.match(regex);
if(!match){
return 'No place to trim'
}
let trimmed = match[0].trim();
let capital = trimmed.replace(/^./, trimmed[0].toUpperCase());
return shortener(str.replace(regex, capital));
};
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
js recursive