String.prototype.trimEndbeginner' hello '.trimEnd() // β ' hello'
'text '.trimEnd() // β 'text'
'hi'.trimEnd() // β 'hi'Use trimEnd() to remove only trailing whitespace from the end of a string, leaving leading whitespace intact.
When both leading and trailing whitespace exist, trimEnd() leaves the leading intact.
Challenge: Implement keepLeading(str) using trimEnd.
keepLeading(' hello ') // β ' hello'