Given a string s and a maximum length maxLength, truncate the string if it exceeds the maximum length.
s.length > maxLength, return the first maxLength characters of s followed by "..."s.length <= maxLength, return s unchangedNote: The "..." is appended after the truncated string, so the total returned length will be maxLength + 3 when truncation occurs.
s = "Hello, World!", maxLength = 5"Hello..."s = "Hi", maxLength = 5"Hi"s = "abcdef", maxLength = 6"abcdef"0 <= s.length <= 10^41 <= maxLength <= 10^4s contains printable ASCII charactersRun your code to see results
Use Cmd+Enter to run