Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Truncate a string-Javascript

function truncateString(str, num) {
  return str.length > num ? str.slice(0, num) + "..." : str;
}
Source by forum.freecodecamp.org #
 
PREVIOUS NEXT
Tagged: #Truncate
ADD COMMENT
Topic
Name
6+5 =