Tell us what’s happening:
This code is exactly out of the hints and solution section buts its showing the first 2 criteria as being not met. Is this a bug?
Your code so far
function truncateString(str, num) {
if (str.length > num && num > 3) {
return str.slice(0, (num - 3)) + '...';
}
else if (str.length > num && num <= 3){
return str.slice(0, num) + '...';
}
else {
return str;
}
}
truncateString("A-tisket a-tasket A green and yellow basket", 8);
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/truncate-a-string