Tell us what’s happening:
I am able to get all the output that I am supposed to get. However, I still fail all the tests. I’m not sure why I’m failing the tests if my output is showing as correct.
Your code so far
function truncateString(string, num) {
let newStr;
if (string.length > num) {
newStr = string.slice(0, num);
return console.log(newStr + "...");
}
else {
newStr = string;
return console.log(newStr);
}
}
let string = "";
truncateString("A-tisket a-tasket A green and yellow basket", 8);
truncateString("Peter Piper picked a peck of pickled peppers", 11);
truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length);
truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2)
truncateString("A-", 1)
truncateString("Absolutely Longer", 2)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:144.0) Gecko/20100101 Firefox/144.0
Challenge Information:
Implement the Truncate String Algorithm - Implement the Truncate a String Algorithm