Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Truncate a string

function truncateString(str, num) {
  // Clear out that junk in your trunk
  if (str.length > num) {
    return str.slice(0, num) + "...";
  } else {
    return str;
  }
}
Comment

Truncate a string

function truncateString(str, num) {
 
  if (str.length > num) {
    return str.slice(0, num) + "...";
  } else {
    return str;
  }
}

truncateString("Lorem Ipsum placeholder text in any number of characters, words sentences or paragraphs", 9)  // returns Lorem Ips...
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to add text to h2 with jquery 
Javascript :: how to check if website is down javascript 
Javascript :: desable no unused vars in vue.js 
Javascript :: append to array js 
Javascript :: js display 2d array 
Javascript :: console log in vue 
Javascript :: how to check if window is loaded javascript 
Javascript :: js filter blur Property 
Javascript :: set value array input jquery 
Javascript :: nuxt router push 
Javascript :: regex to indentify url 
Javascript :: how to remove a property from an object in javascript 
Javascript :: javascript date example 
Javascript :: animate jquery 
Javascript :: axios post with header 
Javascript :: mongoose id from string 
Javascript :: js first letter to uppercase 
Javascript :: import fetch from ("node-fetch"); ^^^^^^ SyntaxError: Cannot use import statement outside a module 
Javascript :: button in javascript 
Javascript :: javascript style multiple properties 
Javascript :: getboundingclientrect() javascript 
Javascript :: javascrpt formatBytes 
Javascript :: javascript take first element of array 
Javascript :: react import css only for component 
Javascript :: jquery window redirect with header 
Javascript :: send form data using fetch 
Javascript :: remove property from javascript object 
Javascript :: on click jquery 
Javascript :: how to get an absolute in js 
Javascript :: Javascript how to compare three numbers 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =