//My solution for this
function truncateString(str, num) {
// Clear out that junk in your trunk
//var newstr = '';
if(num <= 3){
str = str.slice(0,num) + '...';
}
else if(str.length > num){
str = str.slice(0,num-3) + '...';
}
return str;
}
truncateString("A-tisket a-tasket A green and yellow basket", 11);
Its quite simple but was getting stuck. Finally
function truncateString(str, num) {
// Clear out that junk in your trunk
//var newstr = '';
if(num <= 3){
str = str.slice(0,num) + '...';
}
else if(str.length > num){
str = str.slice(0,num-3) + '...';
}
return str;
}
truncateString("A-tisket a-tasket A green and yellow basket", 11);
Its quite simple but was getting stuck. Finally