Tell us what’s happening:
Getting a TypeError: str.slice is not a function. can someone explain why this isn’t working?
Your code so far
const truncateString = (str,num)=> {
let shortString = str.slice(0,num);
let truncate = shortString + "...";
if (str.length >= num && str.length){
return truncate}
else if (str.length <= num){
return str
}
};
console.log(truncateString("A-tisket a-tasket A green and yellow basket".length));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Challenge Information:
Implement the Truncate String Algorithm - Implement the Truncate a String Algorithm
https://www.freecodecamp.org/learn/full-stack-developer/lab-truncate-string/truncate-a-string
