Skip to content

Instantly share code, notes, and snippets.

@JuniorTak
Last active August 29, 2024 15:21
Show Gist options
  • Save JuniorTak/f1e2c4342f3e9001ace8304ba03eae09 to your computer and use it in GitHub Desktop.
Save JuniorTak/f1e2c4342f3e9001ace8304ba03eae09 to your computer and use it in GitHub Desktop.
Excerpt with JavaScript
// excerpt will be the shortened text of content, position being the start index of string method lastIndexOf.
excerpt = content.substr( 0, content.lastIndexOf( ' ', position ) ) + '...';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment