Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function truncateString(str, num) {
- let stringArray = str.length;
- if(stringArray > num){
- return str.slice(0, num) + '...';
- } else if(num => stringArray){
- return str;
- } else{
- return stringArray;
- }
- }
- truncateString("A-tisket a-tasket A green and yellow basket", 8);
Add Comment
Please, Sign In to add comment