Created
August 13, 2018 07:22
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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