Write a function truncate(text, maxLength). If the string is longer than maxLength, cut it and put one … character at the end, so the result is exactly maxLength long. A string that fits in maxLength comes back unchanged.
truncate('Automation testing', 10)Returns 'Automatio…'
truncate('Hello', 5)Returns 'Hello'
truncate('Hello!', 5)Returns 'Hell…'
truncate('Automation testing', 10)'Automatio…'truncate('Hello', 5)'Hello'truncate('Hello!', 5)'Hell…'Hidden tests run on Submit.