Hi, today I finished the exercise “Truncate a String” and after I completed it I checked the “get a hint” to see how they did it. The way I did it didn’t was there so I don’t know if my way of doing it is efficient or not.
Here it is:
function truncateString(str, num) {
// Clear out that junk in your trunk
return (str.length > num) ? str.slice(0, num) + "..." : str;
}
truncateString("A-tisket a-tasket A green and yellow basket", 8);