Tell us what’s happening:
My code looks pretty much identical to the solution given in “get a hint”, I’m not sure where my mistake is?
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 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
.
Link to the challenge: