Truncates a string to a specified length, adding a suffix if needed.
The string to truncate.
The maximum allowed length.
The suffix to add (default is '...').
The truncated string.
truncate('Hello World', 5); // 'Hello...' Copy
truncate('Hello World', 5); // 'Hello...'
Truncates a string to a specified length, adding a suffix if needed.