Created
May 26, 2010 19:34
-
-
Save jimfleming/414939 to your computer and use it in GitHub Desktop.
Automatically truncates a string and appends an ellipsis to the end.
This file contains 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 ellipsis(string, length) { | |
return string.length > length ? (string.substr(0, length - 3) + '...') : string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment