Tell us what’s happening:
I have a problem to get the third and fourth test in the challenge to work
3rd :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”.
4th: 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”.
Please help.
Thanks,
Your code so far
function truncateString(str, num) {
let sub = str.substring(0, num);
return sub + "...";
}
truncateString("A-tisket a-tasket A green and yellow basket", 8);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.108 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-algorithm-scripting/truncate-a-string