Guest User

Untitled

a guest
Jul 23rd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. function truncateString(str, num) {
  2. let stringArray = str.length;
  3. if(stringArray > num){
  4. return str.slice(0, num) + '...';
  5. } else if(num => stringArray){
  6. return str;
  7. } else{
  8. return stringArray;
  9. }
  10. }
  11. truncateString("A-tisket a-tasket A green and yellow basket", 8);
Add Comment
Please, Sign In to add comment