I wanted to remove trailing empty elements and Carriage Return from Array. For example my array looks like this:
Input arr: ['', 'Apple', '', 'Banana', '', 'Guava', '', '', '', '\r']
Required Output: ['', 'Apple', '', 'Banana', '', 'Guava']
Definition of trailing empty elements : After the last valid element ('Guava' in this case), there will not be any other valid element.