Answers for "javascript make text smaller if too long"

2

cut text if too long javascript

if(snippet.length > 1024) {
text = snippet.substring(0, 1024)//cuts to 1024
last = text.lastIndexOf(" ")//gets last space (to avoid cutting the middle of a word)
text = text.substring(0, last)//cuts from last space (to avoid cutting the middle of a word)
text = text + ` (...)`//adds (...) at the end to show that it's cut
}
Posted by: Guest on July-26-2020

Code answers related to "javascript make text smaller if too long"

Code answers related to "Javascript"

Browse Popular Code Answers by Language