Tell us what’s happening:
Hello, I’m not sure of why my code isn’t valid here. The data my function outputs is a string afaik and the cut is made where it should. The result is the same as described in the user story.
Your code so far
function truncateString (string, num){
if (string.length > num){
const stringMax = string.slice(0, num);
const cutString = `${stringMax}... `;
return cutString;
}else return string;
}
truncateString("A-tisket a-tasket A green and yellow basket", 8);
console.log(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; rv:152.0) Gecko/20100101 Firefox/152.0
Challenge Information:
Implement the Truncate String Algorithm - Implement the Truncate a String Algorithm