True full stack in #fintech. Analysis, solutionizing, developing and delivering.
Mostly working in dotnet and javascript, with a passion for process optimising!
Nice. My only comment would be that the ellipsis cut-off should probably subtract the length of the ellipsis, as typically you may want to conform to a database field size. I.e varchar(100) you could end up with 103 chars including the ellipsis,
so like:
function summarize(str, max) {
return str.length > max ? str.substring(0, max-3) + '...' : str;
}
Nice. My only comment would be that the ellipsis cut-off should probably subtract the length of the ellipsis, as typically you may want to conform to a database field size. I.e
varchar(100)
you could end up with 103 chars including the ellipsis,so like:
Even better, it should split at the end of a word and not in the middle of one
Even better, use the unicode ellipsis (
…
;\u2026
).