Created
          April 24, 2019 09:41 
        
      - 
      
- 
        Save mrroot5/0820f3bdffeac8b017675df32030bc0d to your computer and use it in GitHub Desktop. 
    Truncate 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
    
  
  
    
  | const truncateString = (str, num) => | |
| str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str; | |
| truncateString('boomerang', 7); // 'boom...' | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment