Category
The string to trim
The character to remove from the end of string
A string with the leading end
characters removed
trimEnd('aabbcc', 'c'); // 'aabb'
(trimStart:1) to do the same thing but trim from the start of a string
String
Category
Removes the trailing end
characters from an array.
Time complexity: O(n)
Space complexity: O(n)
A shallow-copied array with the trailing start
characters removed
trimEnd(['a', 'a', 'b', 'b', 'c', 'c'], 'c'); // ['a', 'a', 'b', 'b']
(trimStart:2) to do the same thing but trim from the start of an array
Array
Removes the trailing
end
characters from a string.Time complexity: O(n)
Space complexity: O(n)