Skip to content

Instantly share code, notes, and snippets.

View mitchellfyi's full-sized avatar

Mitchell mitchellfyi

View GitHub Profile
@mitchellfyi
mitchellfyi / truncateWallOfTextMeaningfully.js
Last active October 18, 2020 11:53
Truncate a wall of text meaningfully.
var truncateWallOfTextMeaningfully = function (text, lineLength = 50, numOfLines = 5, splitChar = ". ") {
return text
.split(splitChar)
.map(
function (sentence) {
return sentence
.trim()
.substring(0, lineLength)
+ "..."
})