Truncate Text with Ellipsis

function truncateText(text, maxLength) {

  if (text.length > maxLength) {

    return text.substring(0, maxLength) + ‘…’;

  }

  return text;

}

Leave a comment

Your email address will not be published. Required fields are marked *