truncate
Truncates a string to a specified maximum length and appends an ellipsis if the string is longer than the maximum length.
const originalString = 'This is a very long string that needs to be truncated';
const truncatedString = originalString.truncate(30);
console.log(truncatedString); // Outputs: 'This is a very long string tha...'Last updated