` function truncateString(str, num) {
// Clear out that junk in your trunk
if(num > 3){
return str.slice(str, num - 3).concat("...");
}else if(num <= 3){
return str.slice(str, num).concat("...");
}else if(num >= str.length){
return str;
}
}
truncateString("A-tisket a-tasket A green and yellow basket", 11);`
Here is my code. Whether my approach is correct or not?
I’m getting these errors.
-
truncateString(“A-tisket a-tasket A green and yellow basket”, “A-tisket a-tasket A green and yellow basket”.length) should return “A-tisket a-tasket A green and yellow basket”.
-
truncateString(“A-tisket a-tasket A green and yellow basket”, “A-tisket a-tasket A green and yellow basket”.length + 2) should return “A-tisket a-tasket A green and yellow basket”.