Describe your problem and how to reproduce it:
The advance code solution provided in Truncate a String is not able to pass first two test-cases. If you find anything wrong please forgive me.
Add a Link to the page with the problem:
https://guide.freecodecamp.org/certifications/javascript-algorithms-and-data-structures/basic-algorithm-scripting/truncate-a-string/
Tell us about your browser and operating system:
If possible, add a screenshot here (you can drag and drop, png, jpg, gif, etc. in this box):
If you think the problem mentioned above is valid and you want a solution to replace. Here is my code which passed all the test cases.
Code:
function truncateString(str, num) {
// Clear out that junk in your trunk
if(str.length <= num){
return str
}
return str.slice(0, num) + "...";
}
truncateString("A-tisket a-tasket A green and yellow basket", 8);
Proof:
The guide is being moved over to the forum. Here is the post for that challenge. Both of those solutions work, so when the current guide is removed - this shouldn't be an issue.
This can be closed as we are just waiting for master to be shipped to production.