Tell us what’s happening:
Tests 1 & 2 are not passing and I’m not sure what the problem is since the outputs are correct. The other 3 tests passed.
Your code so far
function truncateString(str, num){
if (str.length > num){
return string.slice(0, num) + "...";
} else {
return str;
}
}
let string = "A-tisket a-tasket A green and yellow basket";
console.log(truncateString(string, 8));
string = "Peter Piper picked a peck of pickled peppers";
console.log(truncateString(string, 11));
string = "A-tisket a-tasket A green and yellow basket";
console.log(truncateString(string, "A-tisket a-tasket A green and yellow basket".length));
string = "A-";
console.log(truncateString(string, 1));
string = "Absolutely Longer";
console.log(truncateString(string, 2));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Challenge Information:
Implement the Truncate String Algorithm - Implement the Truncate a String Algorithm