Skip to content

Instantly share code, notes, and snippets.

@arrbxr
Created August 13, 2018 07:22
Show Gist options
  • Save arrbxr/9c609e6f25c9c8175710df3ee4a9a011 to your computer and use it in GitHub Desktop.
Save arrbxr/9c609e6f25c9c8175710df3ee4a9a011 to your computer and use it in GitHub Desktop.
Truncate a String created by arrbxr - https://repl.it/@arrbxr/Truncate-a-String
function truncateString(str, num) {
// Clear out that junk in your trunk
return str.length > num ? str.slice(0, num).concat('...') : str;
}
truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and".length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment