truncate: (str, len) => {
if (str.length > len && str.length>0) {
let new_str = str + ' '
new_str = str.substr(0, len)
new_str = str.substr(0, new_str.lastIndexOf(' '))
new_str = new_str.length > 0 ? new_str : str.substr(0, len)
return new_str + '...'
}
return str
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter