Published
- 1 min read
javascript max length with elipsis
The solution for this is noted below
javascript max length with elipsis
Solution
function truncate_with_ellipsis(s, maxLength) {
if (s.length > maxLength) {
return s.substring(0, maxLength) + '...'
}
return s
}
alert(truncate_with_ellipsis('hello how are you today?', 9)) //hello how...
Try other methods by searching on the site. That is if this doesn’t work