Skip to content

Latest commit

 

History

History
14 lines (9 loc) · 325 Bytes

File metadata and controls

14 lines (9 loc) · 325 Bytes

truncateString()

Overview

Truncates a string to a specified maximum length and adds ellipses if necessary.

Code

A screenshot of the titular code snippet

const truncateString = (str, maxLength) =>
  str.length <= maxLength ? str : str.slice(0, maxLength) + "...";