Skip to content

Instantly share code, notes, and snippets.

@jasdeepkhalsa
Created September 17, 2015 09:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasdeepkhalsa/a9471038c6478b859ef8 to your computer and use it in GitHub Desktop.
Save jasdeepkhalsa/a9471038c6478b859ef8 to your computer and use it in GitHub Desktop.
Truncates a string after a max number of characters
function formatStrTrucate(str, max) {
if (str) {
if (str.length <= max) {
return str;
} else {
return str.slice(0, max) + '...';
}
}
return '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment