Skip to content

Truncates a String at the last word break, with the option to append text to the final String - JavaScript

Notifications You must be signed in to change notification settings

natefollmer/Truncate_at_Wordbreak-JS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Truncate at Wordbreak - Javascript

Truncates a String at the last word break, with the option to append text to the final String - JavaScript

Variables:

  • str - The original String you want truncated
  • len - The max length the final, truncated string can be (this takes into account the appended text)
  • append - Any optional text you would like to append after you truncate str.

Notes:

If text cannot be truncated (the len isn't long enough to reach the first space, with or without your appended text), the function will return the original string.

About

Truncates a String at the last word break, with the option to append text to the final String - JavaScript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published