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
}
Also in JavaScript:
- discord js channel send
- how to apply reduce to an empty array in javascript
- input show validation message
- javascript trim spaces
- running scripts is disabled on this system react js
- first n elements of array js
- javascript get user preferred language
- express json body
- jquery attribute selector
- kill all node process ubunut
- mapping a pojo with json via gson
- use ca certifcate node js
- jQuery UI Sortable, then write order into a database
- javascript base 10 to base 2
- javascript map value nested object
- mysql JSON_SEARCH LIKE
- mongoos populate a ref
- Convert from JSON to Python
- javascript test if it is an array
- mapstatetoprops redux
- get epoch timestamp js
- how to convert entered number into currency in words in javascript
- what does json.parse do
- npm -g