Skip to content

Instantly share code, notes, and snippets.

@bobmacneal
Created February 17, 2020 20:06
Show Gist options
  • Save bobmacneal/13607bc888becf8c9c76baeccfc2add5 to your computer and use it in GitHub Desktop.
Save bobmacneal/13607bc888becf8c9c76baeccfc2add5 to your computer and use it in GitHub Desktop.
export const truncate = (phrase, maxLength) => {
if (phrase.length > maxLength) {
return `${phrase.substring(0, maxLength - 4)} ...`
} else {
return phrase
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment