Created
March 17, 2017 00:43
-
-
Save lachlan-eagling/bd46c31c4bc6fdc3518a24c0a3238cfe to your computer and use it in GitHub Desktop.
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) { | |
| if(num > 3){ | |
| if(str.length > num){ | |
| str = str.slice(0, num - 3); | |
| str += "..."; | |
| } | |
| } else{ | |
| str = str.slice(0, num); | |
| str += "..."; | |
| } | |
| return str; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment