Skip to content

Instantly share code, notes, and snippets.

@SterlingAr
Created January 17, 2017 08:50
Show Gist options
  • Save SterlingAr/8c9f19de0e6d8838d8d9e8d93c3bd948 to your computer and use it in GitHub Desktop.
Save SterlingAr/8c9f19de0e6d8838d8d9e8d93c3bd948 to your computer and use it in GitHub Desktop.
var newString;
if(str.length > num){
newString = str.slice(0,num-3) + "...";
return newString;
}else if(str.length === num || num > str.length){
return str;
}else if( num <= 3){
newString = str.slice(0,num-3) + "...";
return newString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment