Last active
May 30, 2023 12:08
-
-
Save AitorAlejandro/9d3da1c79c935940a0eb272f65ecb25a to your computer and use it in GitHub Desktop.
Truncate strings
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 truncate(str, length) { | |
return str.length > length | |
? `${str.substr(0, length)}...` | |
: str; | |
} |
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 truncate(str: string, length: number): string { | |
return str.length > length | |
? `${str.substr(0, length)}...` | |
: str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment