[spoiler]function truncateString(str, num) {
// Clear out that junk in your trunk
if (str.length <= num) {
return str;
}
else {
return str.slice(num) + '...';
}
}
truncateString("A-tisket a-tasket A green and yellow basket", 8);[/spoiler]
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0.
@camperextraordinaire It is slicing the str by the number in the function string.
I hope it will solve it because It is removing 3 or number if it is greater than three so that it will return the slice.
Even if it pass, having unnecessary code is really bad practice.
Passing the challenge is the lesser thing, the most important thing is learning to code - learning to code means also learning to recognise if a piece of code is useless and should be removed
What I was saying is that num > 0 : num is invalid, it should be just num. That was the answer to this post, but I instead pointed you in the correct direction.